factory_test.go 912 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package collectdreceiver
  4. import (
  5. "context"
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. "go.opentelemetry.io/collector/component/componenttest"
  9. "go.opentelemetry.io/collector/consumer/consumertest"
  10. "go.opentelemetry.io/collector/receiver/receivertest"
  11. )
  12. func TestCreateDefaultConfig(t *testing.T) {
  13. factory := NewFactory()
  14. cfg := factory.CreateDefaultConfig()
  15. assert.NotNil(t, cfg, "failed to create default config")
  16. assert.NoError(t, componenttest.CheckConfigStruct(cfg))
  17. }
  18. func TestCreateReceiver(t *testing.T) {
  19. factory := NewFactory()
  20. cfg := factory.CreateDefaultConfig()
  21. params := receivertest.NewNopCreateSettings()
  22. tReceiver, err := factory.CreateMetricsReceiver(context.Background(), params, cfg, consumertest.NewNop())
  23. assert.NoError(t, err)
  24. assert.NotNil(t, tReceiver, "receiver creation failed")
  25. }