Skip to content

[release-2.13] Add test for skipObject with an argument #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions test/integration/policy_selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var _ = Describe(
status string
}

DescribeTable("Reporting the correct status", func(test selectorTest) {
selectorTestRun := func(test selectorTest) {
By("Patching the objectSelector")
selector, err := json.Marshal(test.selector)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -104,7 +104,10 @@ var _ = Describe(
By("Checking the status")
Eventually(common.GetLatestStatusMessage(policyName, 0),
defaultTimeoutSeconds, 1).Should(Equal(test.status))
},
}

DescribeTable("Reporting the correct status",
selectorTestRun,
Entry("With objectSelector with an empty selector", selectorTest{
selector: []v1.LabelSelectorRequirement{},
status: generateStatus(configMapNames),
Expand All @@ -130,6 +133,24 @@ var _ = Describe(
}),
)

Describe("Using skipObject with an argument", func() {
It("should report the correct status", func() {
By("Patching skipObject to use an argument")
_, err := common.OcHub(
"patch", "policies.policy.open-cluster-management.io", policyName,
"-n", userNamespace, "--type=json", "-p", `[{
"op":"replace",
"path":"/spec/policy-templates/0/objectDefinition/`+
`spec/object-templates/0/objectDefinition/metadata/name",
"value": '{{ not (contains "2" .ObjectName) | skipObject }}{{ .ObjectName }}'}]`)
Expect(err).ToNot(HaveOccurred())
selectorTestRun(selectorTest{
selector: []v1.LabelSelectorRequirement{},
status: generateStatus([]string{"selector-config2"}),
})
})
})

Describe("Reporting correct status with object updates", func() {
// Test definition for adding/removing matching ConfigMaps
It("when a matching ConfigMap is added/removed", func() {
Expand Down