@@ -251,13 +251,17 @@ Spec:
251
251
}
252
252
253
253
func TestPoliciesPrinter_PrintCRDs (t * testing.T ) {
254
+ fakeClock := testingclock .NewFakeClock (time .Now ())
254
255
objects := []runtime.Object {
255
256
& apiextensionsv1.CustomResourceDefinition {
256
257
ObjectMeta : metav1.ObjectMeta {
257
258
Name : "healthcheckpolicies.foo.com" ,
258
259
Labels : map [string ]string {
259
260
gatewayv1alpha2 .PolicyLabelKey : "inherited" ,
260
261
},
262
+ CreationTimestamp : metav1.Time {
263
+ Time : fakeClock .Now ().Add (- 24 * 24 * time .Hour ),
264
+ },
261
265
},
262
266
Spec : apiextensionsv1.CustomResourceDefinitionSpec {
263
267
Scope : apiextensionsv1 .ClusterScoped ,
@@ -300,6 +304,9 @@ func TestPoliciesPrinter_PrintCRDs(t *testing.T) {
300
304
Labels : map [string ]string {
301
305
gatewayv1alpha2 .PolicyLabelKey : "direct" ,
302
306
},
307
+ CreationTimestamp : metav1.Time {
308
+ Time : fakeClock .Now ().Add (- 5 * time .Minute ),
309
+ },
303
310
},
304
311
Spec : apiextensionsv1.CustomResourceDefinitionSpec {
305
312
Scope : apiextensionsv1 .NamespaceScoped ,
@@ -332,15 +339,16 @@ func TestPoliciesPrinter_PrintCRDs(t *testing.T) {
332
339
333
340
params := utils .MustParamsForTest (t , common .MustClientsForTest (t , objects ... ))
334
341
pp := & PoliciesPrinter {
335
- Out : & bytes.Buffer {},
342
+ Out : & bytes.Buffer {},
343
+ Clock : fakeClock ,
336
344
}
337
345
pp .PrintCRDs (params .PolicyManager .GetCRDs ())
338
346
339
347
got := pp .Out .(* bytes.Buffer ).String ()
340
348
want := `
341
- NAME GROUP KIND POLICY TYPE SCOPE
342
- healthcheckpolicies.foo.com foo.com HealthCheckPolicy Inherited Cluster
343
- timeoutpolicies.bar.com bar.com TimeoutPolicy Direct Namespaced
349
+ NAME POLICY TYPE SCOPE AGE
350
+ healthcheckpolicies.foo.com Inherited Cluster 24d
351
+ timeoutpolicies.bar.com Direct Namespaced 5m
344
352
`
345
353
if diff := cmp .Diff (common .YamlString (want ), common .YamlString (got ), common .YamlStringTransformer ); diff != "" {
346
354
t .Errorf ("Unexpected diff\n got=\n %v\n want=\n %v\n diff (-want +got)=\n %v" , got , want , diff )
0 commit comments