@@ -166,6 +166,9 @@ func Test_NewConfig_AppMinimumSyncPeriod(t *testing.T) {
166
166
}
167
167
168
168
func Test_NewConfig_KappDeployRawOptions (t * testing.T ) {
169
+ defaultRawOptions := []string {
170
+ "--app-changes-max-to-keep=5" , "--apply-timeout=5m" ,
171
+ }
169
172
t .Run ("with empty config value, returns just default" , func (t * testing.T ) {
170
173
secret := & v1.Secret {
171
174
ObjectMeta : metav1.ObjectMeta {
@@ -176,7 +179,7 @@ func Test_NewConfig_KappDeployRawOptions(t *testing.T) {
176
179
}
177
180
config , err := kcconfig .NewConfig (k8sfake .NewSimpleClientset (secret ))
178
181
assert .NoError (t , err )
179
- assert .Equal (t , [] string { "--app-changes-max-to-keep=5" } , config .KappDeployRawOptions ())
182
+ assert .Equal (t , defaultRawOptions , config .KappDeployRawOptions ())
180
183
})
181
184
182
185
t .Run ("with empty config value, returns just default" , func (t * testing.T ) {
@@ -191,7 +194,7 @@ func Test_NewConfig_KappDeployRawOptions(t *testing.T) {
191
194
}
192
195
config , err := kcconfig .NewConfig (k8sfake .NewSimpleClientset (secret ))
193
196
assert .NoError (t , err )
194
- assert .Equal (t , [] string { "--app-changes-max-to-keep=5" } , config .KappDeployRawOptions ())
197
+ assert .Equal (t , defaultRawOptions , config .KappDeployRawOptions ())
195
198
})
196
199
197
200
t .Run ("with populated config value, returns default and user set" , func (t * testing.T ) {
@@ -206,7 +209,7 @@ func Test_NewConfig_KappDeployRawOptions(t *testing.T) {
206
209
}
207
210
config , err := kcconfig .NewConfig (k8sfake .NewSimpleClientset (secret ))
208
211
assert .NoError (t , err )
209
- assert .Equal (t , [] string { "--app-changes-max-to-keep=5" , "--key=val" } , config .KappDeployRawOptions ())
212
+ assert .Equal (t , appendNewSlice ( defaultRawOptions , "--key=val" ) , config .KappDeployRawOptions ())
210
213
})
211
214
212
215
t .Run ("clears previously set value when secret is gone" , func (t * testing.T ) {
@@ -223,17 +226,23 @@ func Test_NewConfig_KappDeployRawOptions(t *testing.T) {
223
226
224
227
config , err := kcconfig .NewConfig (client )
225
228
assert .NoError (t , err )
226
- assert .Equal (t , [] string { "--app-changes-max-to-keep=5" , "--key=val" } , config .KappDeployRawOptions ())
229
+ assert .Equal (t , appendNewSlice ( defaultRawOptions , "--key=val" ) , config .KappDeployRawOptions ())
227
230
228
231
err = client .CoreV1 ().Secrets ("default" ).Delete (
229
232
context .Background (), "kapp-controller-config" , metav1.DeleteOptions {})
230
233
assert .NoError (t , err )
231
234
232
235
assert .NoError (t , config .Reload ())
233
- assert .Equal (t , [] string { "--app-changes-max-to-keep=5" } , config .KappDeployRawOptions ())
236
+ assert .Equal (t , defaultRawOptions , config .KappDeployRawOptions ())
234
237
})
235
238
}
236
239
240
+ func appendNewSlice (act []string , items ... string ) []string {
241
+ newslice := make ([]string , 0 )
242
+ newslice = append (newslice , act ... )
243
+ return append (newslice , items ... )
244
+ }
245
+
237
246
func Test_NewConfig_ReturnsConfigMap_WhenOnlyConfigMapExists (t * testing.T ) {
238
247
configMap := & v1.ConfigMap {
239
248
ObjectMeta : metav1.ObjectMeta {
0 commit comments