use std::path::Path;
use crate::{json::FromJson as _, tariff, test};
use super::Tariff;
#[test_each::file(
glob = "ocpi-tariffs/test_data/v221/real_world/*/tariff*.json",
name(segments = 2)
)]
fn should_parse_tariff(tariff_json: &str, path: &Path) {
test::setup();
let expect_json = test::read_expect_json(path, "parse");
let parse_expect = test::parse_expect_json(expect_json.as_deref());
let tariff::ParseReport {
tariff: tariff_elem,
unexpected_fields,
} = tariff::parse_with_version(tariff_json, crate::Version::V221).unwrap();
tariff::test::assert_parse_report(unexpected_fields, parse_expect);
let tariff = Tariff::from_json(tariff_elem.as_element()).unwrap();
let (_tariff, warnings) = tariff.into_parts();
let expect_json = test::read_expect_json(path, "from_json");
let from_json_expect = test::parse_expect_json(expect_json.as_deref());
tariff::test::assert_from_json_warnings(&warnings, from_json_expect);
}