mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-23 08:44:48 -06:00
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:
committed by
Stephan Renatus
parent
92b883d0e0
commit
6415ef17f3
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user