Skip to content

Commit 1605aae

Browse files
CEL Dev Teamcopybara-github
authored andcommitted
Add support for textproto parser for testsuite.
PiperOrigin-RevId: 748701893
1 parent 5b4b234 commit 1605aae

File tree

3 files changed

+100
-14
lines changed

3 files changed

+100
-14
lines changed
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# proto-file: google3/google/api/expr/conformance/test_suite.proto
2-
# proto-message: google.api.expr.conformance.TestSuite
1+
# proto-file: google3/third_party/cel/spec/proto/cel/expr/conformance/test/suite.proto
2+
# proto-message: cel.expr.conformance.test.TestSuite
33

4+
name: "expr_value_output_tests"
45
description: "Value as expected output"
5-
66
sections {
77
name: "basic value"
8+
description: "Basic value"
89
tests {
910
name: "basic value test"
10-
value {
11-
bool_value: true
11+
description: "Basic value test"
12+
output {
13+
result_value {
14+
bool_value: true
15+
}
1216
}
1317
}
1418
}
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
# proto-file: google3/google/api/expr/conformance/test_suite.proto
2-
# proto-message: google.api.expr.conformance.TestSuite
3-
1+
# proto-file: google3/third_party/cel/spec/proto/cel/expr/conformance/test/suite.proto
2+
# proto-message: cel.expr.conformance.test.TestSuite
43
# This testcase is used to test the eval error output in the test runner which
54
# fails because the function is declared in the compiler but not in the runtime.
65

6+
name: "eval_error_tests"
77
description: "Nested rule conformance tests with eval errors"
8-
98
sections {
109
name: "permitted"
10+
description: "Permitted nested rule"
1111
tests {
1212
name: "valid_origin"
13+
description: "Valid origin"
1314
input {
1415
key: "resource"
1516
value {
16-
expr_value {
17+
value {
1718
object_value {
1819
[type.googleapis.com/google.protobuf.Struct] {
1920
fields {
@@ -25,10 +26,12 @@ sections {
2526
}
2627
}
2728
}
28-
eval_error {
29-
errors {
30-
message: "evaluation error: No matching overload for function 'foo'. Overload candidates: foo_id"
29+
output {
30+
eval_error {
31+
errors {
32+
message: "evaluation error: No matching overload for function 'foo'. Overload candidates: foo_id"
33+
}
3134
}
3235
}
3336
}
34-
}
37+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# proto-file: google3/third_party/cel/spec/proto/cel/expr/conformance/test/suite.proto
2+
# proto-message: cel.expr.conformance.test.TestSuite
3+
4+
name: "nested_rule"
5+
description: "Nested rule conformance tests"
6+
sections {
7+
name: "valid"
8+
description: "Valid nested rule"
9+
tests {
10+
name: "restricted_origin"
11+
description: "Restricted origin"
12+
input {
13+
key: "resource"
14+
value {
15+
value {
16+
object_value {
17+
[type.googleapis.com/google.protobuf.Struct] {
18+
fields {
19+
key: "origin"
20+
value { string_value: "ir" }
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}
27+
output {
28+
result_expr: "{'banned': true}"
29+
}
30+
}
31+
tests {
32+
name: "by_default"
33+
description: "By default"
34+
input {
35+
key: "resource"
36+
value {
37+
value {
38+
object_value {
39+
[type.googleapis.com/google.protobuf.Struct] {
40+
fields {
41+
key: "origin"
42+
value { string_value: "'de'" }
43+
}
44+
}
45+
}
46+
}
47+
}
48+
}
49+
output {
50+
result_expr: "{'banned': true}"
51+
}
52+
}
53+
}
54+
55+
sections {
56+
name: "permitted"
57+
description: "Permitted nested rule"
58+
tests {
59+
name: "valid_origin"
60+
input {
61+
key: "resource"
62+
value {
63+
value {
64+
object_value {
65+
[type.googleapis.com/google.protobuf.Struct] {
66+
fields {
67+
key: "origin"
68+
value { string_value: "uk" }
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
output {
76+
result_expr: "{'banned': false}"
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)