Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check query outputs metadata in the test suite. #260

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions trustfall_core/src/interpreter/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1230,11 +1230,32 @@ mod tests {
use crate::{
interpreter::{error::QueryArgumentsError, InterpretedQuery},
ir::{FieldValue, IndexedQuery},
util::TestIRQueryResult,
util::{TestIRQueryResult, TestInterpreterOutputData},
};

#[parameterize("trustfall_core/test_data/tests/valid_queries")]
fn parameterized_output_metadata_tester(base: &Path, stem: &str) {
let mut input_path = PathBuf::from(base);
input_path.push(format!("{stem}.ir.ron"));

let input_data = fs::read_to_string(input_path).unwrap();
let test_query: TestIRQueryResult = ron::from_str(&input_data).unwrap();
let test_query = test_query.unwrap();

let mut check_path = PathBuf::from(base);
check_path.push(format!("{stem}.output.ron"));
let check_data = fs::read_to_string(check_path).unwrap();
let expected_output_data: TestInterpreterOutputData = ron::from_str(&check_data).unwrap();

let indexed_query: IndexedQuery = test_query
.ir_query
.try_into()
.expect("failed to create IndexedQuery");
assert_eq!(expected_output_data.outputs, indexed_query.outputs);
}

#[parameterize("trustfall_core/test_data/tests/execution_errors")]
fn parameterizable_tester(base: &Path, stem: &str) {
fn parameterized_execution_error_tester(base: &Path, stem: &str) {
let mut input_path = PathBuf::from(base);
input_path.push(format!("{stem}.ir.ron"));

Expand Down