@@ -172,12 +172,11 @@ func TestWarehouse_ListFreight(t *testing.T) {
172
172
},
173
173
},
174
174
{
175
- name : "success with VerifiedIn and VerifiedBefore options" ,
175
+ name : "success with VerifiedIn and RequiredSoakTime options" ,
176
176
opts : & ListWarehouseFreightOptions {
177
- ApprovedFor : testStage ,
178
- VerifiedIn : []string {testUpstreamStage },
179
- VerifiedBefore : & metav1.Time {Time : time .Now ().Add (- 1 * time .Hour )},
180
- },
177
+ ApprovedFor : testStage ,
178
+ VerifiedIn : []string {testUpstreamStage },
179
+ RequiredSoakTime : ptr .To (time .Hour )},
181
180
objects : []client.Object {
182
181
& Freight { // This should not be returned
183
182
ObjectMeta : metav1.ObjectMeta {
@@ -194,7 +193,9 @@ func TestWarehouse_ListFreight(t *testing.T) {
194
193
ApprovedFor : map [string ]ApprovedStage {testStage : {}},
195
194
// Doesn't matter that it's verified upstream, because this is the
196
195
// wrong warehouse
197
- VerifiedIn : map [string ]VerifiedStage {testUpstreamStage : {}},
196
+ VerifiedIn : map [string ]VerifiedStage {testUpstreamStage : {
197
+ LongestCompletedSoak : & metav1.Duration {Duration : 2 * time .Hour },
198
+ }},
198
199
},
199
200
},
200
201
& Freight { // This should not be returned
@@ -236,7 +237,7 @@ func TestWarehouse_ListFreight(t *testing.T) {
236
237
// yet elapsed
237
238
VerifiedIn : map [string ]VerifiedStage {
238
239
testUpstreamStage : {
239
- VerifiedAt : ptr . To ( metav1 .Now ()) ,
240
+ LongestCompletedSoak : & metav1.Duration { Duration : 30 * time . Minute } ,
240
241
},
241
242
},
242
243
},
@@ -255,7 +256,7 @@ func TestWarehouse_ListFreight(t *testing.T) {
255
256
// elapsed
256
257
VerifiedIn : map [string ]VerifiedStage {
257
258
testUpstreamStage : {
258
- VerifiedAt : ptr . To ( metav1 .NewTime ( time . Now (). Add ( - 2 * time .Hour ))) ,
259
+ LongestCompletedSoak : & metav1.Duration { Duration : 2 * time .Hour } ,
259
260
},
260
261
},
261
262
},
@@ -276,7 +277,7 @@ func TestWarehouse_ListFreight(t *testing.T) {
276
277
AvailabilityStrategy : FreightAvailabilityStrategyAll ,
277
278
ApprovedFor : testStage ,
278
279
VerifiedIn : []string {testUpstreamStage , testUpstreamStage2 },
279
- VerifiedBefore : & metav1. Time { Time : time . Now (). Add ( - 1 * time .Hour )} ,
280
+ RequiredSoakTime : ptr . To ( time .Hour ),
280
281
},
281
282
objects : []client.Object {
282
283
& Freight { // This should be returned as its approved for the Stage
@@ -292,11 +293,7 @@ func TestWarehouse_ListFreight(t *testing.T) {
292
293
// This is approved for the Stage
293
294
ApprovedFor : map [string ]ApprovedStage {testStage : {}},
294
295
// This is only verified in a single upstream Stage
295
- VerifiedIn : map [string ]VerifiedStage {
296
- testUpstreamStage : {
297
- VerifiedAt : ptr .To (metav1 .Now ()),
298
- },
299
- },
296
+ VerifiedIn : map [string ]VerifiedStage {},
300
297
},
301
298
},
302
299
& Freight { // This should be returned because its verified in both upstream Stages and soak time has lapsed
@@ -314,10 +311,10 @@ func TestWarehouse_ListFreight(t *testing.T) {
314
311
// This is verified in all of the upstream Stages and the soak time has lapsed
315
312
VerifiedIn : map [string ]VerifiedStage {
316
313
testUpstreamStage : {
317
- VerifiedAt : ptr . To ( metav1 .NewTime ( time . Now (). Add ( - 2 * time .Hour ))) ,
314
+ LongestCompletedSoak : & metav1.Duration { Duration : 2 * time .Hour } ,
318
315
},
319
316
testUpstreamStage2 : {
320
- VerifiedAt : ptr . To ( metav1 .NewTime ( time . Now (). Add ( - 2 * time .Hour ))) ,
317
+ LongestCompletedSoak : & metav1.Duration { Duration : 2 * time .Hour } ,
321
318
},
322
319
},
323
320
},
@@ -336,9 +333,7 @@ func TestWarehouse_ListFreight(t *testing.T) {
336
333
ApprovedFor : map [string ]ApprovedStage {},
337
334
// This is not verified in all of the upstream Stages
338
335
VerifiedIn : map [string ]VerifiedStage {
339
- testUpstreamStage : {
340
- VerifiedAt : ptr .To (metav1 .Now ()),
341
- },
336
+ testUpstreamStage : {},
342
337
},
343
338
},
344
339
},
@@ -357,10 +352,10 @@ func TestWarehouse_ListFreight(t *testing.T) {
357
352
// This is verified in all of the upstream Stages but only passed the soak time of one
358
353
VerifiedIn : map [string ]VerifiedStage {
359
354
testUpstreamStage : {
360
- VerifiedAt : ptr . To ( metav1 .NewTime ( time . Now (). Add ( - 2 * time .Hour ))) ,
355
+ LongestCompletedSoak : & metav1.Duration { Duration : 2 * time .Hour } ,
361
356
},
362
357
testUpstreamStage2 : {
363
- VerifiedAt : ptr . To ( metav1 .Now ()) ,
358
+ LongestCompletedSoak : & metav1.Duration { Duration : 30 * time . Minute } ,
364
359
},
365
360
},
366
361
},
@@ -381,7 +376,7 @@ func TestWarehouse_ListFreight(t *testing.T) {
381
376
AvailabilityStrategy : "Invalid" ,
382
377
ApprovedFor : testStage ,
383
378
VerifiedIn : []string {testUpstreamStage , testUpstreamStage2 },
384
- VerifiedBefore : & metav1. Time { Time : time . Now (). Add ( - 1 * time .Hour )} ,
379
+ RequiredSoakTime : ptr . To ( time .Hour ),
385
380
},
386
381
assertions : func (t * testing.T , _ []Freight , err error ) {
387
382
require .ErrorContains (t , err , "unsupported AvailabilityStrategy" )
0 commit comments