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.
69 lines
1.7 KiB
Rust
69 lines
1.7 KiB
Rust
use std::fs;
|
|
|
|
use archlens_domain::{DiagramLevel, ports::ConfigLoader};
|
|
use archlens_toml_config::TomlConfigLoader;
|
|
|
|
#[test]
|
|
fn loads_analysis_config_from_toml_file() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let config_path = dir.path().join("archlens.toml");
|
|
fs::write(
|
|
&config_path,
|
|
r#"
|
|
[analysis]
|
|
exclude = ["tests/", "vendor/"]
|
|
level = "type"
|
|
|
|
[modules]
|
|
"src/orders" = "Orders"
|
|
"src/billing" = "Billing"
|
|
"#,
|
|
)
|
|
.unwrap();
|
|
|
|
let loader = TomlConfigLoader::from_path(&config_path).unwrap();
|
|
let config = loader.load_analysis_config().unwrap();
|
|
|
|
assert_eq!(config.excludes(), &["tests/", "vendor/"]);
|
|
assert_eq!(config.level(), DiagramLevel::Type);
|
|
assert_eq!(
|
|
config.module_mappings().get("src/orders").unwrap(),
|
|
"Orders"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn loads_output_config_from_toml_file() {
|
|
let dir = tempfile::tempdir().unwrap();
|
|
let config_path = dir.path().join("archlens.toml");
|
|
fs::write(
|
|
&config_path,
|
|
r#"
|
|
[output]
|
|
format = "mermaid"
|
|
path = "docs/arch.mmd"
|
|
split_by_module = true
|
|
"#,
|
|
)
|
|
.unwrap();
|
|
|
|
let loader = TomlConfigLoader::from_path(&config_path).unwrap();
|
|
let config = loader.load_output_config().unwrap();
|
|
|
|
assert!(config.split_by_module());
|
|
assert_eq!(config.output_path(), Some("docs/arch.mmd"));
|
|
}
|
|
|
|
#[test]
|
|
fn missing_file_returns_defaults() {
|
|
let loader = TomlConfigLoader::default();
|
|
|
|
let analysis = loader.load_analysis_config().unwrap();
|
|
assert!(analysis.excludes().is_empty());
|
|
assert_eq!(analysis.level(), DiagramLevel::Module);
|
|
|
|
let output = loader.load_output_config().unwrap();
|
|
assert!(!output.split_by_module());
|
|
assert!(output.output_path().is_none());
|
|
}
|