Skip to content

Commit

Permalink
Add test to load empty config.
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed May 5, 2020
1 parent 328a96b commit f0d96e4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

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

"github.com/open-telemetry/opentelemetry-collector/config/configmodels"
)
Expand Down Expand Up @@ -407,3 +408,25 @@ func TestDecodeConfig_Invalid(t *testing.T) {
}
}
}

func TestLoadEmptyConfig(t *testing.T) {
factories, err := ExampleComponents()
assert.NoError(t, err)

// Open the file for reading.
file, err := os.Open(path.Join(".", "testdata", "empty-config.yaml"))
require.NoError(t, err)

defer func() {
require.NoError(t, file.Close())
}()

// Read yaml config from file
v := NewViper()
v.SetConfigType("yaml")
require.NoError(t, v.ReadConfig(file))

// Load the config from viper using the given factories.
_, err = Load(v, factories)
assert.NoError(t, err)
}

0 comments on commit f0d96e4

Please sign in to comment.