Skip to content

Commit

Permalink
Remove configtest dependency from collector, generate tests in builder (
Browse files Browse the repository at this point in the history
#4607)

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Dec 21, 2021
1 parent 8e1b819 commit ec90e1f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 115 deletions.
4 changes: 0 additions & 4 deletions service/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ type Collector struct {

// New creates and returns a new instance of Collector.
func New(set CollectorSettings) (*Collector, error) {
if err := validateConfigFromFactories(set.Factories); err != nil {
return nil, err
}

if set.ConfigProvider == nil {
return nil, errors.New("invalid nil config provider")
}
Expand Down
25 changes: 25 additions & 0 deletions service/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
package service

import (
"context"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/internal/internalinterface"
"go.opentelemetry.io/collector/internal/testcomponents"
)

Expand Down Expand Up @@ -49,3 +53,24 @@ func TestNewCommandInvalidFactories(t *testing.T) {
err = cmd.Execute()
require.Error(t, err)
}

// badConfigExtensionFactory was created to force error path from factory returning
// a config not satisfying the validation.
type badConfigExtensionFactory struct {
internalinterface.BaseInternal
}

func (b badConfigExtensionFactory) Type() config.Type {
return "bad_config"
}

func (b badConfigExtensionFactory) CreateDefaultConfig() config.Extension {
return &struct {
config.ExtensionSettings
BadTagField int `mapstructure:"tag-with-dashes"`
}{}
}

func (b badConfigExtensionFactory) CreateExtension(_ context.Context, _ component.ExtensionCreateSettings, _ config.Extension) (component.Extension, error) {
return nil, nil
}
43 changes: 0 additions & 43 deletions service/configcheck.go

This file was deleted.

68 changes: 0 additions & 68 deletions service/configcheck_test.go

This file was deleted.

0 comments on commit ec90e1f

Please sign in to comment.