From c0f041174a133d412442f2a97655d7ee54c2077d Mon Sep 17 00:00:00 2001 From: Premkumar Bhaskal Date: Wed, 22 Nov 2023 21:30:39 +0530 Subject: [PATCH] fix tests Signed-off-by: Premkumar Bhaskal --- pkg/config/config_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 47c44562d..e7d935eeb 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -166,6 +166,7 @@ func Test_NewConfig_AppMinimumSyncPeriod(t *testing.T) { } func Test_NewConfig_KappDeployRawOptions(t *testing.T) { + defaultRawOptions := []string{"--app-changes-max-to-keep=5", "--kube-api-qps=50", "--kube-api-burst=100"} t.Run("with empty config value, returns just default", func(t *testing.T) { secret := &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -176,7 +177,7 @@ func Test_NewConfig_KappDeployRawOptions(t *testing.T) { } config, err := kcconfig.NewConfig(k8sfake.NewSimpleClientset(secret)) assert.NoError(t, err) - assert.Equal(t, []string{"--app-changes-max-to-keep=5"}, config.KappDeployRawOptions()) + assert.Equal(t, defaultRawOptions, config.KappDeployRawOptions()) }) t.Run("with empty config value, returns just default", func(t *testing.T) { @@ -206,7 +207,10 @@ func Test_NewConfig_KappDeployRawOptions(t *testing.T) { } config, err := kcconfig.NewConfig(k8sfake.NewSimpleClientset(secret)) assert.NoError(t, err) - assert.Equal(t, []string{"--app-changes-max-to-keep=5", "--key=val"}, config.KappDeployRawOptions()) + var expRawOptions []string + expRawOptions = append(expRawOptions, defaultRawOptions...) + expRawOptions = append(expRawOptions, "--key=val") + assert.Equal(t, expRawOptions, config.KappDeployRawOptions()) }) t.Run("clears previously set value when secret is gone", func(t *testing.T) { @@ -223,14 +227,17 @@ func Test_NewConfig_KappDeployRawOptions(t *testing.T) { config, err := kcconfig.NewConfig(client) assert.NoError(t, err) - assert.Equal(t, []string{"--app-changes-max-to-keep=5", "--key=val"}, config.KappDeployRawOptions()) + var expRawOptions []string + expRawOptions = append(expRawOptions, defaultRawOptions...) + expRawOptions = append(expRawOptions, "--key=val") + assert.Equal(t, expRawOptions, config.KappDeployRawOptions()) err = client.CoreV1().Secrets("default").Delete( context.Background(), "kapp-controller-config", metav1.DeleteOptions{}) assert.NoError(t, err) assert.NoError(t, config.Reload()) - assert.Equal(t, []string{"--app-changes-max-to-keep=5"}, config.KappDeployRawOptions()) + assert.Equal(t, defaultRawOptions, config.KappDeployRawOptions()) }) }