extern crate redirectionio;
#[rustfmt::skip]
mod generated_tests {
use redirectionio::api::{TestExamplesInput, TestExamplesOutput};
use serde_json::{from_str as json_decode, to_string_pretty as json_encode};
use std::env;
{%- for name in names %}
#[test]
fn test_examples_{{ name }}() {
do_test("{{ name }}");
}
{%- endfor %}
fn do_test(name: &str) {
let json_in = std::fs::read_to_string(format!("tests/test_examples/{}.in.json", name)).unwrap();
let test_examples_input: TestExamplesInput = json_decode(&json_in).unwrap();
let test_examples = TestExamplesOutput::create_result_without_project(test_examples_input);
let json_out_expected = std::fs::read_to_string(format!("tests/test_examples/{}.out.json", name)).unwrap();
let json_out = json_encode(&test_examples).unwrap();
if env::var("RIO_UPDATE_FIXTURES").is_ok() {
std::fs::write(format!("tests/test_examples/{}.out.json", name), &json_out).unwrap();
return;
}
if json_out != json_out_expected {
std::fs::write(format!("tests/test_examples/{}.out.current.json", name), &json_out).unwrap();
}
assert_eq!(json_out, json_out_expected, "check for tests/test_examples/{}.out.current.json", name);
}
}