Files
regorus/tests/interpreter/cases/input/mod.rs
Anand Krishnamoorthi 800e594d52 Arity for builtins (#28)
Old-style function call

Utility for running opa yaml tests

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-10-24 10:11:50 -07:00

48 lines
862 B
Rust

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![cfg(test)]
use crate::interpreter::*;
use anyhow::Result;
#[test]
fn basic() -> Result<()> {
let rego = r#"
package test
x[a] {
a = y
}
y[a] {
a = input.x + 5
}
"#;
let input = ValueOrVec::Many(vec![
Value::from_json_str(r#"{"x": 1}"#)?,
Value::from_json_str(r#"{"x": 6}"#)?,
]);
let expected = [
Value::from_json_str(
r#" {
"y": {"set!": [6]},
"x": {"set!": [{"set!":[6]}]}
}"#,
)?,
Value::from_json_str(
r#" {
"y": {"set!": [11]},
"x": {"set!": [{"set!":[11]}]}
}"#,
)?,
];
check_output(
&eval_file_first_rule(&[rego.to_owned()], None, Some(input), "data.test", false)?,
&expected,
)
}