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>
This commit is contained in:
Dmitry Frenkel
2025-11-03 21:26:53 -08:00
committed by Stephan Renatus
parent 92b883d0e0
commit 6415ef17f3
2 changed files with 26 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
---
cases:
- note: time.now_ns/consistent value for same evaluation
query: data.test.p = x
modules:
- |
package test
p := count(times) if {
times := {time.now_ns() | numbers.range(1, 100)[_]}
}
want_result:
- x: 1
+13
View File
@@ -0,0 +1,13 @@
---
cases:
- note: uuid.rfc4122/consistent values for same arguments
query: data.test.p = x
modules:
- |
package test
p := count(uuids) if {
uuids := {uuid.rfc4122("key") | numbers.range(1, 100)[_]}
}
want_result:
- x: 1