Skip to content

Commit

Permalink
fix: remove the duplicated test case for updateConfig
Browse files Browse the repository at this point in the history
Signed-off-by: terry.hung <[email protected]>
  • Loading branch information
Terryhung committed Nov 8, 2024
1 parent b634fde commit 75b42b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
6 changes: 4 additions & 2 deletions flytestdlib/config/tests/accessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,11 @@ func TestAccessor_UpdateConfig(t *testing.T) {
key := strings.ToUpper("my-component.str3")
assert.NoError(t, os.Setenv(key, "Set From Env"))
defer func() { assert.NoError(t, os.Unsetenv(key)) }()
assert.NoError(t, v.UpdateConfig(context.TODO()))
err = v.UpdateConfig(context.TODO())
assert.Error(t, err)
assert.EqualError(t, err, "Config File \"config\" Not Found in \"[]\"")
r := reg.GetSection(MyComponentSectionKey).GetConfig().(*MyComponentConfig)
assert.Equal(t, "Set From Env", r.StringValue3)
assert.Equal(t, "", r.StringValue3)
})

t.Run(fmt.Sprintf("[%v] Change handler", provider(config.Options{}).ID()), func(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions flytestdlib/config/viper/testdata/viper_test_config.yaml

This file was deleted.

29 changes: 0 additions & 29 deletions flytestdlib/config/viper/viper_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package viper

import (
"context"
"encoding/base64"
"reflect"
"testing"

"github.com/flyteorg/flyte/flytestdlib/config"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -54,30 +52,3 @@ func Test_stringToByteArray(t *testing.T) {
assert.NotEqual(t, []byte("hello"), res)
})
}

func TestViperAccessor_UpdateConfig(t *testing.T) {
ctx := context.Background()
t.Run("unable to find the config file", func(t *testing.T) {
// Create accessor
accessor := newAccessor(config.Options{
SearchPaths: []string{".", "/etc/flyte/config", "$GOPATH/src/github.com/flyteorg/flyte"},
StrictMode: false,
})

// Update config
err := accessor.updateConfig(ctx, accessor.rootConfig)
assert.EqualError(t, err, "Config File \"config\" Not Found in \"[]\"")
})

t.Run("find the config file", func(t *testing.T) {
// Create accessor
accessor := newAccessor(config.Options{
SearchPaths: []string{"./testdata/viper_test_config.yaml"},
StrictMode: false,
})

// Update config
err := accessor.updateConfig(ctx, accessor.rootConfig)
assert.NoError(t, err)
})
}

0 comments on commit 75b42b1

Please sign in to comment.