init: archlens — architecture diagram generator
Some checks failed
CI / Check / Test (push) Failing after 1m24s
Some checks failed
CI / Check / Test (push) Failing after 1m24s
Hex arch + DDD, tree-sitter parsing, Mermaid/ASCII output. Supports Rust + Python. 92 tests. CI, diff, --check for staleness detection.
This commit is contained in:
43
crates/application/tests/fakes/source_analyzer.rs
Normal file
43
crates/application/tests/fakes/source_analyzer.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use archlens_domain::{AnalysisResult, DomainError, SourceFile, ports::SourceAnalyzer};
|
||||
|
||||
enum FakeResponse {
|
||||
Success(AnalysisResult),
|
||||
Failure(DomainError),
|
||||
}
|
||||
|
||||
pub struct FakeSourceAnalyzer {
|
||||
results: HashMap<String, FakeResponse>,
|
||||
}
|
||||
|
||||
impl FakeSourceAnalyzer {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
results: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_result(mut self, file_path: &str, result: AnalysisResult) -> Self {
|
||||
self.results
|
||||
.insert(file_path.to_string(), FakeResponse::Success(result));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_error(mut self, file_path: &str, error: DomainError) -> Self {
|
||||
self.results
|
||||
.insert(file_path.to_string(), FakeResponse::Failure(error));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl SourceAnalyzer for FakeSourceAnalyzer {
|
||||
fn analyze_file(&self, file: &SourceFile) -> Result<AnalysisResult, DomainError> {
|
||||
let key = file.path().as_str().to_string();
|
||||
match self.results.get(&key) {
|
||||
Some(FakeResponse::Success(result)) => Ok(result.clone()),
|
||||
Some(FakeResponse::Failure(_)) => Err(DomainError::AnalysisError(key)),
|
||||
None => Ok(AnalysisResult::empty()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user