factory_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package sumologicexporter
  4. import (
  5. "testing"
  6. "time"
  7. "github.com/stretchr/testify/assert"
  8. "go.opentelemetry.io/collector/component"
  9. "go.opentelemetry.io/collector/component/componenttest"
  10. "go.opentelemetry.io/collector/config/confighttp"
  11. "go.opentelemetry.io/collector/exporter/exporterhelper"
  12. )
  13. func TestType(t *testing.T) {
  14. factory := NewFactory()
  15. pType := factory.Type()
  16. assert.Equal(t, pType, component.Type("sumologic"))
  17. }
  18. func TestCreateDefaultConfig(t *testing.T) {
  19. factory := NewFactory()
  20. cfg := factory.CreateDefaultConfig()
  21. qs := exporterhelper.NewDefaultQueueSettings()
  22. qs.Enabled = false
  23. assert.Equal(t, cfg, &Config{
  24. CompressEncoding: "gzip",
  25. MaxRequestBodySize: 1_048_576,
  26. LogFormat: "json",
  27. MetricFormat: "prometheus",
  28. SourceCategory: "",
  29. SourceName: "",
  30. SourceHost: "",
  31. Client: "otelcol",
  32. GraphiteTemplate: "%{_metric_}",
  33. HTTPClientSettings: confighttp.HTTPClientSettings{
  34. Timeout: 5 * time.Second,
  35. },
  36. RetrySettings: exporterhelper.NewDefaultRetrySettings(),
  37. QueueSettings: qs,
  38. })
  39. assert.NoError(t, componenttest.CheckConfigStruct(cfg))
  40. }