Skip to content

Commit 2514b99

Browse files
committed
Fix tests
1 parent c373ce0 commit 2514b99

16 files changed

+20
-238
lines changed

acceptance.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020

2121
@test "[CREATE] Creating constraints using --output matches expected output" {
22-
run ./build/konstraint create test/policies --output test/output/standard
22+
run ./build/konstraint create test/policies --partial-constraints --output test/output/standard
2323
[ "$status" -eq 0 ]
2424
git diff --quiet -- test/output/standard
2525
}

internal/commands/create_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestRenderConstraint(t *testing.T) {
1919
t.Errorf("Error getting violations: %v", err)
2020
}
2121

22-
expected, err := os.ReadFile("../../test/constraint_Test.yaml")
22+
expected, err := os.ReadFile("../../test/output/standard/constraint_FullMetadata.yaml")
2323
if err != nil {
2424
t.Errorf("Error reading expected file: %v", err)
2525
}
@@ -48,7 +48,7 @@ func TestRenderConstraintWithCustomTemplate(t *testing.T) {
4848
t.Errorf("Error getting violations: %v", err)
4949
}
5050

51-
expected, err := os.ReadFile("../../test/custom/constraint_Test.yaml")
51+
expected, err := os.ReadFile("../../test/output/custom/constraint_FullMetadata.yaml")
5252
if err != nil {
5353
t.Errorf("Error reading expected file: %v", err)
5454
}
@@ -77,7 +77,7 @@ func TestRenderConstraintTemplate(t *testing.T) {
7777
t.Errorf("Error getting violations: %v", err)
7878
}
7979

80-
expected, err := os.ReadFile("../../test/template_Test.yaml")
80+
expected, err := os.ReadFile("../../test/output/standard/template_FullMetadata.yaml")
8181
if err != nil {
8282
t.Errorf("Error reading expected file: %v", err)
8383
}
@@ -106,7 +106,7 @@ func TestRenderConstraintTemplateWithCustomTemplate(t *testing.T) {
106106
t.Errorf("Error getting violations: %v", err)
107107
}
108108

109-
expected, err := os.ReadFile("../../test/custom/template_Test.yaml")
109+
expected, err := os.ReadFile("../../test/output/custom/template_FullMetadata.yaml")
110110
if err != nil {
111111
t.Errorf("Error reading expected file: %v", err)
112112
}
@@ -129,7 +129,7 @@ func TestRenderConstraintTemplateWithCustomTemplate(t *testing.T) {
129129
}
130130

131131
func GetViolations() ([]rego.Rego, error) {
132-
violations, err := rego.GetViolations("../../test")
132+
violations, err := rego.GetViolations("../../test/policies/")
133133
if err != nil {
134134
return nil, err
135135
}

test/output/custom/constraint_Policies.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

test/output/custom/constraint_Test.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

test/output/custom/template_FullMetadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
- |-
2626
package lib.libraryB
2727
rego: |-
28-
package test
28+
package test_fullmetadata
2929
3030
import future.keywords.if
3131
import data.lib.libraryA

test/output/custom/template_PartialMetadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
- |-
1818
package lib.libraryB
1919
rego: |-
20-
package test_partial_metadata
20+
package test_partialmetadata
2121
2222
import future.keywords.if
2323
import data.lib.libraryA

test/output/custom/template_Policies.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/output/custom/template_Test.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/output/standard/constraint_Test.yaml renamed to test/output/standard/constraint_FullMetadata.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: constraints.gatekeeper.sh/v1beta1
2-
kind: Test
2+
kind: FullMetadata
33
metadata:
4-
name: test
4+
name: fullmetadata
55
spec:
66
match:
77
excludedNamespaces:
@@ -31,3 +31,5 @@ spec:
3131
- dev
3232
- stage
3333
- prod
34+
parameters:
35+
super: null

test/output/standard/template_FullMetadata.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: templates.gatekeeper.sh/v1beta1
1+
apiVersion: templates.gatekeeper.sh/v1
22
kind: ConstraintTemplate
33
metadata:
44
creationTimestamp: null
@@ -16,6 +16,7 @@ spec:
1616
super duper cool parameter with a description
1717
on two lines.
1818
type: string
19+
type: object
1920
targets:
2021
- libs:
2122
- |-
@@ -24,7 +25,7 @@ spec:
2425
import data.lib.libraryB
2526
- package lib.libraryB
2627
rego: |-
27-
package test
28+
package test_fullmetadata
2829
2930
import future.keywords.if
3031
import data.lib.libraryA

0 commit comments

Comments
 (0)