factory_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package mongodbreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver"
  4. import (
  5. "context"
  6. "testing"
  7. "time"
  8. "github.com/stretchr/testify/require"
  9. "go.opentelemetry.io/collector/component"
  10. "go.opentelemetry.io/collector/consumer/consumertest"
  11. "go.opentelemetry.io/collector/receiver/receivertest"
  12. "go.opentelemetry.io/collector/receiver/scraperhelper"
  13. )
  14. func TestType(t *testing.T) {
  15. factory := NewFactory()
  16. ft := factory.Type()
  17. require.EqualValues(t, "mongodb", ft)
  18. }
  19. func TestValidConfig(t *testing.T) {
  20. factory := NewFactory()
  21. require.NoError(t, component.ValidateConfig(factory.CreateDefaultConfig()))
  22. }
  23. func TestCreateMetricsReceiver(t *testing.T) {
  24. factory := NewFactory()
  25. _, err := factory.CreateMetricsReceiver(
  26. context.Background(),
  27. receivertest.NewNopCreateSettings(),
  28. &Config{
  29. ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
  30. CollectionInterval: 10 * time.Second,
  31. InitialDelay: time.Second,
  32. },
  33. },
  34. consumertest.NewNop(),
  35. )
  36. require.NoError(t, err)
  37. }