Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Premkumar Bhaskal <[email protected]>
  • Loading branch information
prembhaskal committed Nov 22, 2023
1 parent f25dab1 commit c0f0411
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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())
})
}

Expand Down

0 comments on commit c0f0411

Please sign in to comment.