archunit/files/assertion/
file_pattern_violation.rsuse crate::common::{Filter, ProjectedNode};
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct FilePatternViolation {
pub check_filter: Filter,
pub projected_node: ProjectedNode,
pub is_negated: bool,
}
impl FilePatternViolation {
#[must_use]
pub const fn new(
check_filter: Filter,
projected_node: ProjectedNode,
is_negated: bool,
) -> Self {
Self {
check_filter,
projected_node,
is_negated,
}
}
}
#[cfg(test)]
mod tests {
use crate::common::{Graph, PatternTarget, RegexFactory, project_to_nodes};
use super::FilePatternViolation;
#[test]
fn retains_the_requirement_file_evidence_and_mood() {
let node = project_to_nodes(&Graph::from_edges([crate::common::Edge::self_edge(
"src/order_service.rs",
)]))
.into_iter()
.next()
.expect("fixture graph should project one node");
let filter = RegexFactory::default()
.filename_matcher("*_service.rs")
.expect("fixture pattern should compile");
let violation = FilePatternViolation::new(filter, node, true);
assert_eq!(violation.check_filter.target(), PatternTarget::Filename);
assert_eq!(violation.check_filter.pattern().source(), "*_service.rs");
assert_eq!(violation.projected_node.label, "src/order_service.rs");
assert!(violation.is_negated);
}
}