@@ -92,11 +92,11 @@ func newClusterWithOptions(_ testing.TB, opts []UpdateSettingsFunc, objs ...runt
9292 client .PrependReactor ("list" , "*" , func (action testcore.Action ) (handled bool , ret runtime.Object , err error ) {
9393 handled , ret , err = reactor .React (action )
9494 if err != nil || ! handled {
95- return
95+ return handled , ret , fmt . Errorf ( "reactor failed: %w" , err )
9696 }
9797 // make sure list response have resource version
9898 ret .(metav1.ListInterface ).SetResourceVersion ("123" )
99- return
99+ return handled , ret , nil
100100 })
101101
102102 apiResources := []kube.APIResourceInfo {{
@@ -1158,12 +1158,12 @@ func TestIterateHierachyV2(t *testing.T) {
11581158 })
11591159}
11601160
1161- // TestIterateHierarchyV2_CrossNamespaceOwnerReference tests that cross-namespace
1162- // owner references work correctly, specifically cluster-scoped resources with
1161+ // TestIterateHierarchyV2_CrossNamespaceOwnerReference tests that cross-namespace
1162+ // owner references work correctly, specifically cluster-scoped resources with
11631163// namespaced children
11641164func TestIterateHierarchyV2_CrossNamespaceOwnerReference (t * testing.T ) {
11651165 cluster := newCluster (t )
1166-
1166+
11671167 // Create cluster-scoped parent resource (ProviderRevision)
11681168 parentUID := types .UID ("parent-uid-123" )
11691169 clusterScopedParent := & Resource {
@@ -1220,35 +1220,36 @@ func TestIterateHierarchyV2_CrossNamespaceOwnerReference(t *testing.T) {
12201220 var visitedResources []* Resource
12211221 cluster .IterateHierarchyV2 (
12221222 []kube.ResourceKey {clusterScopedParent .ResourceKey ()},
1223- func (resource * Resource , namespaceResources map [kube.ResourceKey ]* Resource ) bool {
1223+ func (resource * Resource , _ map [kube.ResourceKey ]* Resource ) bool {
12241224 visitedResources = append (visitedResources , resource )
12251225 return true
12261226 },
12271227 )
12281228
12291229 // Should visit parent + both children (3 resources)
1230- assert .Equal (t , 3 , len ( visitedResources ) , "Should visit parent and both children" )
1231-
1230+ assert .Len (t , visitedResources , 3 , "Should visit parent and both children" )
1231+
12321232 visitedNames := make ([]string , len (visitedResources ))
12331233 for i , res := range visitedResources {
12341234 visitedNames [i ] = res .Ref .Name
12351235 }
1236-
1236+
12371237 // Check we have the expected resources by type and namespace combination
12381238 foundParent := false
12391239 foundClusterChild := false
12401240 foundNamespacedChild := false
1241-
1241+
12421242 for _ , res := range visitedResources {
1243- if res .Ref .Kind == "ProviderRevision" && res .Ref .Namespace == "" {
1243+ switch {
1244+ case res .Ref .Kind == "ProviderRevision" && res .Ref .Namespace == "" :
12441245 foundParent = true
1245- } else if res .Ref .Kind == "ClusterRole" && res .Ref .Namespace == "" {
1246+ case res .Ref .Kind == "ClusterRole" && res .Ref .Namespace == "" :
12461247 foundClusterChild = true
1247- } else if res .Ref .Kind == "Deployment" && res .Ref .Namespace == "crossplane-system" {
1248+ case res .Ref .Kind == "Deployment" && res .Ref .Namespace == "crossplane-system" :
12481249 foundNamespacedChild = true
12491250 }
12501251 }
1251-
1252+
12521253 assert .True (t , foundParent , "Should visit ProviderRevision parent" )
12531254 assert .True (t , foundClusterChild , "Should visit ClusterRole child" )
12541255 assert .True (t , foundNamespacedChild , "Should visit Deployment child (this tests the fix)" )
@@ -1286,7 +1287,7 @@ func Test_watchEvents_Deadlock(t *testing.T) {
12861287 // deadlock.RLock()
12871288 // defer deadlock.RUnlock()
12881289
1289- return
1290+ return info , cacheManifest
12901291 }),
12911292 }, res1 , res2 , testDeploy ())
12921293 defer func () {
0 commit comments