From 75b42b1072da412960d2d57efd43fd8a7b36df76 Mon Sep 17 00:00:00 2001 From: "terry.hung" Date: Fri, 8 Nov 2024 12:40:16 +0800 Subject: [PATCH] fix: remove the duplicated test case for updateConfig Signed-off-by: terry.hung --- flytestdlib/config/tests/accessor_test.go | 6 ++-- .../viper/testdata/viper_test_config.yaml | 2 -- flytestdlib/config/viper/viper_test.go | 29 ------------------- 3 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 flytestdlib/config/viper/testdata/viper_test_config.yaml diff --git a/flytestdlib/config/tests/accessor_test.go b/flytestdlib/config/tests/accessor_test.go index 6210adea36..6c471aece5 100644 --- a/flytestdlib/config/tests/accessor_test.go +++ b/flytestdlib/config/tests/accessor_test.go @@ -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) { diff --git a/flytestdlib/config/viper/testdata/viper_test_config.yaml b/flytestdlib/config/viper/testdata/viper_test_config.yaml deleted file mode 100644 index 8878ae7652..0000000000 --- a/flytestdlib/config/viper/testdata/viper_test_config.yaml +++ /dev/null @@ -1,2 +0,0 @@ -test: - val: 1 diff --git a/flytestdlib/config/viper/viper_test.go b/flytestdlib/config/viper/viper_test.go index 6ef5f65f7a..881d4436f2 100644 --- a/flytestdlib/config/viper/viper_test.go +++ b/flytestdlib/config/viper/viper_test.go @@ -1,12 +1,10 @@ package viper import ( - "context" "encoding/base64" "reflect" "testing" - "github.com/flyteorg/flyte/flytestdlib/config" "github.com/stretchr/testify/assert" ) @@ -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) - }) -}