Skip to content

Commit

Permalink
test(e2e): Refactor test helper to use slices package (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson authored Feb 26, 2024
1 parent e538f4b commit 604db96
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions test/e2e/clusterresourceset_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,28 @@ func waitForClusterResourceSetToApplyResources(
continue
}

// Fix a bug from upstream to check all bindings.
resourceApplied := false
for _, binding := range binding.Spec.Bindings {
if binding.IsApplied(resource) {
resourceApplied = true
break
}
}
if !resourceApplied {
// Check relevant ResourceSetBinding to see if the resource is applied. If no ResourceSetBinding is found for
// the specified ClusterResourceSet, the resource has not applied.
resourceSetBinding, found := getResourceSetBindingForClusterResourceSet(
binding,
input.ClusterResourceSet,
)
if !found || !resourceSetBinding.IsApplied(resource) {
return false
}
}
return true
}, intervals...).Should(BeTrue())
}

func getResourceSetBindingForClusterResourceSet(
clusterResourceSetBinding *addonsv1.ClusterResourceSetBinding,
clusterResourceSet *addonsv1.ClusterResourceSet,
) (*addonsv1.ResourceSetBinding, bool) {
for _, binding := range clusterResourceSetBinding.Spec.Bindings {
if binding.ClusterResourceSetName == clusterResourceSet.Name {
return binding, true
}
}
return nil, false
}

0 comments on commit 604db96

Please sign in to comment.