@@ -229,6 +229,7 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T)
229
229
pgParamBlockList map [string ]bool
230
230
rbs * BackupConfig
231
231
srcDB * Postgres
232
+ image string
232
233
want string
233
234
wantErr bool
234
235
}{
@@ -257,6 +258,7 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T)
257
258
Description : "description" ,
258
259
},
259
260
},
261
+ image : "image:tag" ,
260
262
want : time .Now ().Format (zalando_timestamp_format ), // I know this is not perfect, let's just hope we always finish within the same second...
261
263
wantErr : false ,
262
264
},
@@ -283,6 +285,7 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T)
283
285
Description : "description" ,
284
286
},
285
287
},
288
+ image : "image:tag" ,
286
289
want : time .Now ().Format (zalando_timestamp_format ), // I know this is not perfect, let's just hope we always finish within the same second...
287
290
wantErr : false ,
288
291
},
@@ -311,6 +314,7 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T)
311
314
Description : "description" ,
312
315
},
313
316
},
317
+ image : "image:tag" ,
314
318
want : "invalid but whatever" ,
315
319
wantErr : false ,
316
320
},
@@ -339,17 +343,47 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T)
339
343
Description : "description" ,
340
344
},
341
345
},
346
+ image : "image:tag" ,
342
347
want : "oranges" ,
343
348
wantErr : true ,
344
349
},
350
+ {
351
+ name : "no image" ,
352
+ spec : PostgresSpec {
353
+ Size : & Size {
354
+ CPU : "1" ,
355
+ Memory : "4Gi" ,
356
+ SharedBuffer : "64Mi" ,
357
+ },
358
+ PostgresRestore : & PostgresRestore {
359
+ Timestamp : "apples" ,
360
+ },
361
+ },
362
+ c : nil ,
363
+ sc : "fake-storage-class" ,
364
+ pgParamBlockList : map [string ]bool {},
365
+ rbs : & BackupConfig {},
366
+ srcDB : & Postgres {
367
+ ObjectMeta : v1.ObjectMeta {
368
+ Name : uuid .NewString (),
369
+ },
370
+ Spec : PostgresSpec {
371
+ Tenant : "tenant" ,
372
+ Description : "description" ,
373
+ },
374
+ },
375
+ image : "" ,
376
+ want : time .Now ().Format (zalando_timestamp_format ), // I know this is not perfect, let's just hope we always finish within the same second...
377
+ wantErr : false ,
378
+ },
345
379
}
346
380
for _ , tt := range tests {
347
381
tt := tt // pin!
348
382
t .Run (tt .name , func (t * testing.T ) {
349
383
p := & Postgres {
350
384
Spec : tt .spec ,
351
385
}
352
- got , _ := p .ToUnstructuredZalandoPostgresql (nil , tt .c , tt .sc , tt .pgParamBlockList , tt .rbs , tt .srcDB , 130 , 10 , 60 , false , false )
386
+ got , _ := p .ToUnstructuredZalandoPostgresql (nil , tt .c , tt .sc , tt .pgParamBlockList , tt .rbs , tt .srcDB , 130 , 10 , 60 , false , false , "dockerImage" )
353
387
354
388
jsonZ , err := runtime .DefaultUnstructuredConverter .ToUnstructured (got )
355
389
if err != nil {
@@ -358,7 +392,7 @@ func TestPostgresRestoreTimestamp_ToUnstructuredZalandoPostgresql(t *testing.T)
358
392
jsonSpec , _ := jsonZ ["spec" ].(map [string ]interface {})
359
393
jsonClone , _ := jsonSpec ["clone" ].(map [string ]interface {})
360
394
361
- if ! tt .wantErr && tt .want != jsonClone ["timestamp" ] {
395
+ if ! tt .wantErr && tt .want != jsonClone ["timestamp" ] && tt . image == jsonSpec [ "dockerImage" ] {
362
396
t .Errorf ("Spec.Clone.Timestamp was %v, but expected %v" , jsonClone ["timestamp" ], tt .want )
363
397
}
364
398
})
0 commit comments