github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/pkg/config/provider_test.go (about) 1 package config_test 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/kyma-incubator/compass/components/director/pkg/config" 8 9 "github.com/stretchr/testify/assert" 10 "github.com/stretchr/testify/require" 11 ) 12 13 func TestProvider_Load(t *testing.T) { 14 t.Run("returns error when file not found", func(t *testing.T) { 15 // GIVEN 16 sut := config.NewProvider("not_existing_file.yaml") 17 // WHEN 18 err := sut.Load() 19 // THEN 20 require.Error(t, err) 21 assert.True(t, strings.HasPrefix(err.Error(), "while reading file not_existing_file.yaml")) 22 }) 23 24 t.Run("returns error on invalid yaml", func(t *testing.T) { 25 // GIVEN 26 sut := config.NewProvider("testdata/invalid.yaml") 27 // WHEN 28 err := sut.Load() 29 // THEN 30 require.EqualError(t, err, "while unmarshalling YAML: error converting YAML to JSON: yaml: found unexpected end of stream") 31 }) 32 }