fn load_fixture(name: &str) -> Vec<u8> {
let path = std::env::var("CARGO_MANIFEST_DIR")
.unwrap()
.parse::<std::path::PathBuf>()
.unwrap();
let path = path
.join("..")
.join("fixtures")
.join(&format!("{name}.json"));
std::fs::read(path).unwrap()
}
#[test]
fn it_correctly_deserializes_json() {
let base = load_fixture("01-oc-1.3pre-sansibar");
let result = serde_json::from_slice::<openconfiguration::Scene>(&base).unwrap();
insta::with_settings!(
{sort_maps => true},
{
insta::assert_json_snapshot!(result);
}
);
}
#[test]
fn it_correctly_deserializes_json_with_multiple_products() {
let base = load_fixture("02-oc-1.3pre-provita");
let result = serde_json::from_slice::<openconfiguration::Scene>(&base).unwrap();
insta::with_settings!(
{sort_maps => true},
{
insta::assert_json_snapshot!(result);
}
);
}
#[test]
fn it_correctly_deserializes_oc_1_0_json() {
let base = load_fixture("03-oc-1.0");
let result = serde_json::from_slice::<openconfiguration::Scene>(&base).unwrap();
insta::with_settings!(
{sort_maps => true},
{
insta::assert_json_snapshot!(result);
}
);
}
#[test]
fn it_correctly_deserializes_icom_1_3_json() {
let base = load_fixture("04-oc-1.3pre-icom");
let result = serde_json::from_slice::<openconfiguration::Scene>(&base).unwrap();
insta::with_settings!(
{sort_maps => true},
{
insta::assert_json_snapshot!(result);
}
);
}
#[test]
fn it_correctly_deserializes_oc_cns_json() {
let base = load_fixture("05-oc-cns");
let result = serde_json::from_slice::<openconfiguration::Scene>(&base).unwrap();
insta::with_settings!(
{sort_maps => true},
{
insta::assert_json_snapshot!(result);
}
);
}