@@ -333,6 +333,61 @@ func TestVerify(t *testing.T) {
333333 No invalid ownerReferences found
334334 ` ,
335335 },
336+ {
337+ name : "case-different references" ,
338+ resources : []* metav1.APIResourceList {
339+ v1Resources ,
340+ {
341+ GroupVersion : "group1/v1" ,
342+ APIResources : []metav1.APIResource {{Name : "multiversionresources" , SingularName : "multiversionresource" , Namespaced : true , Kind : "MultiVersionKind" , Verbs : gcVerbs }},
343+ },
344+ {
345+ GroupVersion : "group1/v1beta1" ,
346+ APIResources : []metav1.APIResource {{Name : "multiversionresources" , SingularName : "multiversionresource" , Namespaced : true , Kind : "MultiVersionKind" , Verbs : gcVerbs }},
347+ },
348+ },
349+ adjustMetadataClient : func (metadataClient * metadatafake.FakeMetadataClient ) {
350+ addObject (t , metadataClient , "group1/v1" , "multiversionresources" , "MultiVersionKind" , "mgr1" , "ns1" , "mgruid1" )
351+ addObject (t , metadataClient , "v1" , "pods" , "Pod" , "exact" , "ns1" , "poduid1" ,
352+ metav1.OwnerReference {APIVersion : "group1/v1beta1" , Kind : "MultiVersionKind" , Name : "mgr1" , UID : types .UID ("mgruid1" )},
353+ )
354+ addObject (t , metadataClient , "v1" , "pods" , "Pod" , "lowercase" , "ns1" , "poduid1" ,
355+ metav1.OwnerReference {APIVersion : "group1/v1beta1" , Kind : "multiversionkind" , Name : "mgr1" , UID : types .UID ("mgruid1" )},
356+ )
357+ addObject (t , metadataClient , "v1" , "pods" , "Pod" , "uppercase" , "ns1" , "poduid1" ,
358+ metav1.OwnerReference {APIVersion : "group1/v1beta1" , Kind : "MULTIVERSIONKIND" , Name : "mgr1" , UID : types .UID ("mgruid1" )},
359+ )
360+ addObject (t , metadataClient , "v1" , "pods" , "Pod" , "edgecase" , "ns1" , "poduid1" ,
361+ metav1.OwnerReference {APIVersion : "group1/v1beta1" , Kind : "MultiversionkinD" , Name : "mgr1" , UID : types .UID ("mgruid1" )},
362+ )
363+ addObject (t , metadataClient , "v1" , "pods" , "Pod" , "pluralkind" , "ns1" , "poduid1" ,
364+ metav1.OwnerReference {APIVersion : "group1/v1beta1" , Kind : "multiversionkinds" , Name : "mgr1" , UID : types .UID ("mgruid1" )},
365+ )
366+ addObject (t , metadataClient , "v1" , "pods" , "Pod" , "pluralresource" , "ns1" , "poduid1" ,
367+ metav1.OwnerReference {APIVersion : "group1/v1beta1" , Kind : "multiversionresources" , Name : "mgr1" , UID : types .UID ("mgruid1" )},
368+ )
369+ addObject (t , metadataClient , "v1" , "pods" , "Pod" , "singularresource" , "ns1" , "poduid1" ,
370+ metav1.OwnerReference {APIVersion : "group1/v1beta1" , Kind : "multiversionresource" , Name : "mgr1" , UID : types .UID ("mgruid1" )},
371+ )
372+ },
373+ expectOut : `
374+ GROUP RESOURCE NAMESPACE NAME OWNER_UID LEVEL MESSAGE
375+ pods ns1 edgecase mgruid1 Error cannot resolve owner apiVersion/kind: no matches for kind "MultiversionkinD" in version "group1/v1beta1"
376+ pods ns1 pluralkind mgruid1 Error cannot resolve owner apiVersion/kind: no matches for kind "multiversionkinds" in version "group1/v1beta1"
377+ pods ns1 pluralresource mgruid1 Error cannot resolve owner apiVersion/kind: no matches for kind "multiversionresources" in version "group1/v1beta1"
378+ pods ns1 singularresource mgruid1 Error cannot resolve owner apiVersion/kind: no matches for kind "multiversionresource" in version "group1/v1beta1"
379+ pods ns1 uppercase mgruid1 Error cannot resolve owner apiVersion/kind: no matches for kind "MULTIVERSIONKIND" in version "group1/v1beta1"
380+ ` ,
381+ expectErr : `
382+ fetching v1, nodes
383+ got 0 items
384+ fetching v1, pods
385+ got 7 items
386+ fetching group1/v1, multiversionresources
387+ got 1 item
388+ 5 errors, 0 warnings
389+ ` ,
390+ },
336391 }
337392
338393 klog .InitFlags (nil )
0 commit comments