Skip to content

Commit 9fa0905

Browse files
author
Liudmila Molkova
authored
Add test for enum member id format (#2273)
1 parent 98bf65c commit 9fa0905

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

policies_test/yaml_schema_test.rego

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ test_fails_on_attribute_name_without_namespace if {
1212
count(deny) >= 1 with input as {"groups": create_attribute_group("foo")}
1313
}
1414

15+
test_fails_on_invalid_attribute_member_id if {
16+
every name in invalid_names {
17+
count(deny) >= 1 with input as {"groups": [{"id": "yaml_schema.test", "attributes": [{"id": "foo.bar", "stability": "rc", "type": {
18+
"members": [{
19+
"id": name,
20+
"value": "test",
21+
"stability": "stable",
22+
}]
23+
}}]}]}
24+
}
25+
}
26+
1527
test_fails_on_invalid_metric_name if {
1628
every name in invalid_names {
1729
count(deny) >= 1 with input as {"groups": create_metric(name)}
@@ -75,6 +87,18 @@ test_passes_on_valid_names if {
7587
}
7688
}
7789

90+
test_passes_on_valid_attribute_member_id if {
91+
every name in valid_names {
92+
count(deny) == 0 with input as {"groups": [{"id": "yaml_schema.test", "attributes": [{"id": "foo.bar", "stability": "rc", "type": {
93+
"members": [{
94+
"id": name,
95+
"value": "test",
96+
"stability": "stable",
97+
}]
98+
}}]}]}
99+
}
100+
}
101+
78102
test_fails_if_prefix_is_present if {
79103
count(deny) == 1 with input as {"groups": [{"id": "test", "prefix": "foo"}]}
80104
}
@@ -132,6 +156,8 @@ invalid_names := [
132156
"foo_.bar",
133157
"foo.bar,baz",
134158
"fü.bär",
159+
"Foo.bar",
160+
"foo.bAR",
135161
]
136162

137163
valid_names := [

0 commit comments

Comments
 (0)