use super::consistency::check_life_status_consistency;
use super::status_defect::StatusDefect;
#[test]
fn a_status_its_edges_support_is_consistent() {
assert_eq!(
check_life_status_consistency(Some("remanufactured"), &["remanufacturing"]),
None
);
assert_eq!(
check_life_status_consistency(Some("re-used"), &["preparationForReuse"]),
None
);
}
#[test]
fn either_repurposing_operation_supports_repurposed() {
for operation in ["repurposing", "preparationForRepurposing"] {
assert_eq!(
check_life_status_consistency(Some("repurposed"), &[operation]),
None,
"{operation} must support a repurposed unit"
);
}
}
#[test]
fn a_status_no_edge_supports_is_reported() {
assert_eq!(
check_life_status_consistency(Some("remanufactured"), &["repurposing"]),
Some(StatusDefect::NoEdgeSupportsStatus {
status: "remanufactured"
})
);
}
#[test]
fn a_second_life_status_with_no_edges_is_reported() {
assert_eq!(
check_life_status_consistency(Some("repurposed"), &[]),
Some(StatusDefect::NoEdgeSupportsStatus {
status: "repurposed"
})
);
}
#[test]
fn mixed_predecessors_are_consistent_with_either_status() {
let edges = ["repurposing", "remanufacturing"];
assert_eq!(
check_life_status_consistency(Some("repurposed"), &edges),
None
);
assert_eq!(
check_life_status_consistency(Some("remanufactured"), &edges),
None
);
}
#[test]
fn original_with_a_derivation_edge_is_reported() {
assert_eq!(
check_life_status_consistency(Some("original"), &["repurposing"]),
Some(StatusDefect::OriginalIsDerived {
operation: "repurposing"
})
);
}
#[test]
fn original_with_no_edges_is_consistent() {
assert_eq!(check_life_status_consistency(Some("original"), &[]), None);
}
#[test]
fn waste_is_consistent_with_any_lineage() {
for edges in [
&[][..],
&["repurposing"][..],
&["remanufacturing", "preparationForReuse"][..],
] {
assert_eq!(
check_life_status_consistency(Some("waste"), edges),
None,
"waste must not be checked against {edges:?}"
);
}
}
#[test]
fn an_absent_status_is_consistent() {
assert_eq!(check_life_status_consistency(None, &["repurposing"]), None);
assert_eq!(check_life_status_consistency(None, &[]), None);
}
#[test]
fn a_status_outside_the_annex_is_reported() {
for status in ["approaching end of life", "reused", "Original", ""] {
assert_eq!(
check_life_status_consistency(Some(status), &["repurposing"]),
Some(StatusDefect::UnknownStatus { status }),
"{status:?} is not one of the five values point 4(c) enumerates"
);
}
}