archunit/files/assertion/
file_dependency_violation.rsuse crate::common::ProjectedEdge;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct FileDependencyViolation {
pub dependency: ProjectedEdge,
pub is_negated: bool,
}
impl FileDependencyViolation {
#[must_use]
pub const fn new(dependency: ProjectedEdge, is_negated: bool) -> Self {
Self {
dependency,
is_negated,
}
}
}
#[cfg(test)]
mod tests {
use crate::common::{Edge, ImportKind, ProjectedEdge};
use super::FileDependencyViolation;
#[test]
fn retains_projected_and_raw_dependency_evidence_with_the_mood() {
let raw = Edge::new("src/api.rs", "src/database.rs", false, [ImportKind::Use]);
let dependency = ProjectedEdge::new("src/api.rs", "src/database.rs", [raw.clone()]);
let violation = FileDependencyViolation::new(dependency, true);
assert_eq!(violation.dependency.source_label, "src/api.rs");
assert_eq!(violation.dependency.target_label, "src/database.rs");
assert_eq!(violation.dependency.cumulated_edges, [raw]);
assert!(violation.is_negated);
}
}