test(statuswait): add more tests suggested by Copilot code review

add missing coverage for the positive case where cluster-scoped resources (like ClusterRole or Namespace) should work correctly

Signed-off-by: Mohsen Mottaghi <mohsenmottaghi@outlook.com>
(cherry picked from commit a1543d5947)
release-4.0
Mohsen Mottaghi 2 months ago committed by Scott Rigby
parent 3818c02f81
commit 2a2e6f722a
No known key found for this signature in database
GPG Key ID: C7C6FBB5B91C1155

@ -569,6 +569,34 @@ func TestStatusWaitMultipleNamespaces(t *testing.T) {
return sw.WaitForDelete(rl, timeout)
},
},
{
name: "cluster-scoped resources work correctly with unrestricted permissions",
objManifests: []string{podNamespace1Manifest, clusterRoleManifest},
testFunc: func(sw statusWaiter, rl ResourceList, timeout time.Duration) error {
return sw.Wait(rl, timeout)
},
},
{
name: "namespace-scoped and cluster-scoped resources work together",
objManifests: []string{podNamespace1Manifest, podNamespace2Manifest, clusterRoleManifest},
testFunc: func(sw statusWaiter, rl ResourceList, timeout time.Duration) error {
return sw.Wait(rl, timeout)
},
},
{
name: "delete cluster-scoped resources works correctly",
objManifests: []string{podNamespace1Manifest, namespaceManifest},
testFunc: func(sw statusWaiter, rl ResourceList, timeout time.Duration) error {
return sw.WaitForDelete(rl, timeout)
},
},
{
name: "watch cluster-scoped resources works correctly",
objManifests: []string{clusterRoleManifest},
testFunc: func(sw statusWaiter, rl ResourceList, timeout time.Duration) error {
return sw.WatchUntilReady(rl, timeout)
},
},
}
for _, tt := range tests {
@ -579,6 +607,8 @@ func TestStatusWaitMultipleNamespaces(t *testing.T) {
fakeMapper := testutil.NewFakeRESTMapper(
v1.SchemeGroupVersion.WithKind("Pod"),
batchv1.SchemeGroupVersion.WithKind("Job"),
schema.GroupVersion{Group: "rbac.authorization.k8s.io", Version: "v1"}.WithKind("ClusterRole"),
v1.SchemeGroupVersion.WithKind("Namespace"),
)
sw := statusWaiter{
client: fakeClient,

Loading…
Cancel
Save