Skip to content

Commit 2a147cb

Browse files
committed
Fix tests
1 parent c373ce0 commit 2a147cb

15 files changed

+17
-237
lines changed

internal/commands/create_test.go

+5-5
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

-34
This file was deleted.

test/output/custom/constraint_Test.yaml

-34
This file was deleted.

test/output/custom/template_FullMetadata.yaml

+1-1
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

+1-1
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

-38
This file was deleted.

test/output/custom/template_Test.yaml

-38
This file was deleted.

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

+2-2
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:

test/output/standard/template_FullMetadata.yaml

+3-2
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

test/output/standard/template_NoMetadata.yaml

+1-1
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

test/output/standard/template_PartialMetadata.yaml

+2-2
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,7 +16,7 @@ spec:
1616
import data.lib.libraryB
1717
- package lib.libraryB
1818
rego: |-
19-
package test_partial_metadata
19+
package test_partialmetadata
2020
2121
import future.keywords.if
2222
import data.lib.libraryA

test/output/standard/template_Policies.yaml

-38
This file was deleted.

test/output/standard/template_Test.yaml

-39
This file was deleted.

test/policies/full-metadata/src.rego

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# - dev
3737
# - stage
3838
# - prod
39-
package test
39+
package test_fullmetadata
4040

4141
import future.keywords.if
4242
import data.lib.libraryA

test/policies/partial-metadata/src.rego

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# - dev
88
# - stage
99
# - prod
10-
package test_partial_metadata
10+
package test_partialmetadata
1111

1212
import future.keywords.if
1313
import data.lib.libraryA

0 commit comments

Comments
 (0)