Files
archlens/crates/adapters/toml-config/tests/toml_config_tests.rs
Gabriel Kaszewski 35f27d00b0
Some checks failed
CI / Check / Test (push) Failing after 1m24s
init: archlens — architecture diagram generator
Hex arch + DDD, tree-sitter parsing, Mermaid/ASCII output.
Supports Rust + Python. 92 tests. CI, diff, --check for staleness detection.
2026-06-16 16:13:04 +02:00

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());
}