#![allow(clippy::missing_panics_doc, reason = "tests are allowed to panic")]
#![allow(clippy::panic, reason = "tests are allowed panic")]
use crate::{
schema,
test::{self, ExpectFile, Expectation},
warning,
};
#[derive(Debug, serde::Deserialize)]
pub struct SchemaExpect {
#[serde(default)]
warnings_schema: Expectation<test::WarningMap>,
}
#[derive(Debug, serde::Deserialize)]
pub struct DomainExpect {
#[serde(default)]
warnings_domain: Expectation<test::WarningMap>,
}
#[track_caller]
pub(crate) fn assert_schema_warnings(
warnings: &warning::Set<schema::Warning>,
expect: ExpectFile<SchemaExpect>,
) {
let ExpectFile {
value,
expect_file_name,
} = expect;
let warnings_schema = value
.map(|SchemaExpect { warnings_schema }| warnings_schema)
.unwrap_or(Expectation::Absent);
warning::test::assert_warnings(
&format!("`warnings_schema` in the `{expect_file_name}` file"),
warnings,
warnings_schema,
);
}
#[track_caller]
pub(crate) fn assert_domain_warnings(
warnings: &warning::Set<super::Warning>,
expect: ExpectFile<DomainExpect>,
) {
let ExpectFile {
value,
expect_file_name,
} = expect;
let warnings_domain = value
.map(|DomainExpect { warnings_domain }| warnings_domain)
.unwrap_or(Expectation::Absent);
warning::test::assert_warnings(
&format!("`warnings_domain` in the `{expect_file_name}` file"),
warnings,
warnings_domain,
);
}