Skip to content

Commit 6415ef1

Browse files
DFrenkelsrenatus
authored andcommitted
Add test cases for consistent cache behavior
Using `rand.intn` test cases as template, we create similar tests that verify consistent values returned by `uuid.rfc4122` and `time.now_ns` builtins when invoked during the same evaluation/query. These tests can also aid compliance regression testing for other OPA implementations, such as Swift. Signed-off-by: Dmitry Frenkel <d_frenkel@apple.com>
1 parent 92b883d commit 6415ef1

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
cases:
3+
- note: time.now_ns/consistent value for same evaluation
4+
query: data.test.p = x
5+
modules:
6+
- |
7+
package test
8+
9+
p := count(times) if {
10+
times := {time.now_ns() | numbers.range(1, 100)[_]}
11+
}
12+
want_result:
13+
- x: 1
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
cases:
3+
- note: uuid.rfc4122/consistent values for same arguments
4+
query: data.test.p = x
5+
modules:
6+
- |
7+
package test
8+
9+
p := count(uuids) if {
10+
uuids := {uuid.rfc4122("key") | numbers.range(1, 100)[_]}
11+
}
12+
want_result:
13+
- x: 1

0 commit comments

Comments
 (0)