use std::collections::BTreeMap;
use crate::{Version, json, tariff, test, warning};
#[test]
fn a_bound_that_cannot_be_read_is_reported_once() {
test::setup();
let source = r#"{
"country_code": "NL",
"party_id": "TDR",
"currency": "EUR",
"id": "ID",
"last_updated": "2024-01-01T00:00:00Z",
"elements": [
{
"price_components": [{"price": 0.25, "step_size": 1, "type": "ENERGY"}],
"restrictions": {"min_duration": 10, "max_duration": -5}
}
]
}"#;
let doc = json::parse_object(source).unwrap();
let tariff = tariff::from_json(doc, Version::V221).ignore_warnings();
let warnings = tariff::lint(&tariff).warnings;
assert_eq!(
warnings.path_id_map(),
BTreeMap::from([(
"$.elements[0].restrictions.max_duration",
vec![warning::Id::from_static("invalid")],
)]),
);
}