@@ -92,11 +92,11 @@ func newClusterWithOptions(_ testing.TB, opts []UpdateSettingsFunc, objs ...runt
92
92
client .PrependReactor ("list" , "*" , func (action testcore.Action ) (handled bool , ret runtime.Object , err error ) {
93
93
handled , ret , err = reactor .React (action )
94
94
if err != nil || ! handled {
95
- return
95
+ return handled , ret , fmt . Errorf ( "reactor failed: %w" , err )
96
96
}
97
97
// make sure list response have resource version
98
98
ret .(metav1.ListInterface ).SetResourceVersion ("123" )
99
- return
99
+ return handled , ret , nil
100
100
})
101
101
102
102
apiResources := []kube.APIResourceInfo {{
@@ -1158,12 +1158,12 @@ func TestIterateHierachyV2(t *testing.T) {
1158
1158
})
1159
1159
}
1160
1160
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
1163
1163
// namespaced children
1164
1164
func TestIterateHierarchyV2_CrossNamespaceOwnerReference (t * testing.T ) {
1165
1165
cluster := newCluster (t )
1166
-
1166
+
1167
1167
// Create cluster-scoped parent resource (ProviderRevision)
1168
1168
parentUID := types .UID ("parent-uid-123" )
1169
1169
clusterScopedParent := & Resource {
@@ -1220,35 +1220,36 @@ func TestIterateHierarchyV2_CrossNamespaceOwnerReference(t *testing.T) {
1220
1220
var visitedResources []* Resource
1221
1221
cluster .IterateHierarchyV2 (
1222
1222
[]kube.ResourceKey {clusterScopedParent .ResourceKey ()},
1223
- func (resource * Resource , namespaceResources map [kube.ResourceKey ]* Resource ) bool {
1223
+ func (resource * Resource , _ map [kube.ResourceKey ]* Resource ) bool {
1224
1224
visitedResources = append (visitedResources , resource )
1225
1225
return true
1226
1226
},
1227
1227
)
1228
1228
1229
1229
// 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
+
1232
1232
visitedNames := make ([]string , len (visitedResources ))
1233
1233
for i , res := range visitedResources {
1234
1234
visitedNames [i ] = res .Ref .Name
1235
1235
}
1236
-
1236
+
1237
1237
// Check we have the expected resources by type and namespace combination
1238
1238
foundParent := false
1239
1239
foundClusterChild := false
1240
1240
foundNamespacedChild := false
1241
-
1241
+
1242
1242
for _ , res := range visitedResources {
1243
- if res .Ref .Kind == "ProviderRevision" && res .Ref .Namespace == "" {
1243
+ switch {
1244
+ case res .Ref .Kind == "ProviderRevision" && res .Ref .Namespace == "" :
1244
1245
foundParent = true
1245
- } else if res .Ref .Kind == "ClusterRole" && res .Ref .Namespace == "" {
1246
+ case res .Ref .Kind == "ClusterRole" && res .Ref .Namespace == "" :
1246
1247
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" :
1248
1249
foundNamespacedChild = true
1249
1250
}
1250
1251
}
1251
-
1252
+
1252
1253
assert .True (t , foundParent , "Should visit ProviderRevision parent" )
1253
1254
assert .True (t , foundClusterChild , "Should visit ClusterRole child" )
1254
1255
assert .True (t , foundNamespacedChild , "Should visit Deployment child (this tests the fix)" )
@@ -1286,7 +1287,7 @@ func Test_watchEvents_Deadlock(t *testing.T) {
1286
1287
// deadlock.RLock()
1287
1288
// defer deadlock.RUnlock()
1288
1289
1289
- return
1290
+ return info , cacheManifest
1290
1291
}),
1291
1292
}, res1 , res2 , testDeploy ())
1292
1293
defer func () {
0 commit comments