refactor: CheckFreshness and DiffDiagram take &str instead of &Path
This commit is contained in:
43
crates/application/tests/check_freshness_tests.rs
Normal file
43
crates/application/tests/check_freshness_tests.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
mod fakes;
|
||||
|
||||
use archlens_domain::{CodeGraph, NormalizedGraph, ports::DiagramRenderer};
|
||||
use archlens_application::use_cases::check_freshness::CheckFreshness;
|
||||
use fakes::FakeDiagramRenderer;
|
||||
|
||||
fn empty_graph() -> NormalizedGraph {
|
||||
NormalizedGraph::from_project(CodeGraph::new())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_true_when_content_matches() {
|
||||
let graph = empty_graph();
|
||||
let renderer = FakeDiagramRenderer::new();
|
||||
let rendered = renderer.render(graph.as_graph()).unwrap();
|
||||
let existing = rendered.files().first().unwrap().content().to_string();
|
||||
|
||||
let result = CheckFreshness {
|
||||
graph: &graph,
|
||||
renderer: &renderer,
|
||||
existing_content: &existing,
|
||||
}
|
||||
.execute()
|
||||
.unwrap();
|
||||
|
||||
assert!(result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_false_when_content_differs() {
|
||||
let graph = empty_graph();
|
||||
let renderer = FakeDiagramRenderer::new();
|
||||
|
||||
let result = CheckFreshness {
|
||||
graph: &graph,
|
||||
renderer: &renderer,
|
||||
existing_content: "stale content that does not match",
|
||||
}
|
||||
.execute()
|
||||
.unwrap();
|
||||
|
||||
assert!(!result);
|
||||
}
|
||||
Reference in New Issue
Block a user