Skip to content

Commit e52dec9

Browse files
committed
test: add obj sel tests
Signed-off-by: Janelle Law <[email protected]>
1 parent 5e53ecd commit e52dec9

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Status compare:
2+
.compliant: 'NonCompliant' does match 'NonCompliant'
3+
.relatedObjects[0] matches
4+
.relatedObjects[1] matches
5+
.relatedObjects[2] matches
6+
.relatedObjects matches
7+
Expected status matches the actual status
8+
9+
# Diffs:
10+
networking.k8s.io/v1 Ingress default/good-ingress:
11+
12+
networking.k8s.io/v1 Ingress default/wrong-1-ingress:
13+
--- default/wrong-1-ingress : existing
14+
+++ default/wrong-1-ingress : updated
15+
@@ -7,11 +7,11 @@
16+
name: wrong-1-ingress
17+
namespace: default
18+
spec:
19+
- ingressClassName: wrong-name
20+
+ ingressClassName: test
21+
rules:
22+
- http:
23+
paths:
24+
- backend:
25+
service:
26+
networking.k8s.io/v1 Ingress default/wrong-2-ingress:
27+
--- default/wrong-2-ingress : existing
28+
+++ default/wrong-2-ingress : updated
29+
@@ -7,11 +7,11 @@
30+
name: wrong-2-ingress
31+
namespace: default
32+
spec:
33+
- ingressClassName: wrong-name
34+
+ ingressClassName: test
35+
rules:
36+
- http:
37+
paths:
38+
- backend:
39+
service:
40+
# Compliance messages:
41+
NonCompliant; violation - ingresses [wrong-1-ingress, wrong-2-ingress] found but not as specified in namespace default

test/e2e/case46_dryrun_cli_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ var _ = Describe("Testing dryrun CLI", Ordered, func() {
169169
})
170170
})
171171

172+
Describe("Object Selector Tests", func() {
173+
testObjectSelector := map[string]string{
174+
"musthave_mixed_noncompliant": "Test musthave mixed compliant and noncompliant with 3 matched resources",
175+
"mustnothave_mixed_noncompliant": "Test mustnothave mixed compliant and noncompliant with 2 matched resources",
176+
}
177+
178+
It("Should handle object selector scenarios", func() {
179+
for testDir, testName := range testObjectSelector {
180+
By("Testing object selector " + testName)
181+
testDryrunScenario("no_name/with_object_selector", testDir, testName)
182+
}
183+
})
184+
})
185+
172186
Describe("No Name Cluster Scope Tests", func() {
173187
testNoNameCluster := map[string]string{
174188
"compliant_related_obj": "Test cluster-scoped compliant objects",

0 commit comments

Comments
 (0)