Rustelo/tests/integration/config_merging.rs
Jesús Pérez 0d0297423e
Some checks failed
CI/CD Pipeline / Test Suite (push) Has been cancelled
CI/CD Pipeline / Security Audit (push) Has been cancelled
CI/CD Pipeline / Performance Benchmarks (push) Has been cancelled
Rust CI / Security Audit (push) Has been cancelled
Rust CI / Check + Test + Lint (nightly) (push) Has been cancelled
Rust CI / Check + Test + Lint (stable) (push) Has been cancelled
CI/CD Pipeline / Build Docker Image (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Cleanup (push) Has been cancelled
chore: fix with CI and pre-commit
2026-02-08 20:37:49 +00:00

90 lines
1.9 KiB
Rust

//! Configuration merging tests
use anyhow::Result;
use std::fs;
#[test]
fn test_toml_config_merging() -> Result<()> {
let temp_project = crate::create_test_project()?;
let project_root = temp_project.path();
// Create base config
let base_config = r#"
[app]
name = "test-app"
version = "1.0.0"
[database]
host = "localhost"
port = 5432
"#;
let config_path = project_root.join("config.toml");
fs::write(&config_path, base_config)?;
// Create feature config to merge
let feature_config = r#"
[database]
ssl = true
pool_size = 10
[analytics]
enabled = true
endpoint = "http://analytics.example.com"
"#;
// Test merging (would use ConfigurationIntegrator)
// Expected result should have both sections merged
Ok(())
}
#[test]
fn test_json_config_merging() -> Result<()> {
let temp_project = crate::create_test_project()?;
let project_root = temp_project.path();
// Test JSON configuration merging
let base_json = r#"{
"app": {
"name": "test-app",
"features": ["basic"]
}
}"#;
let feature_json = r#"{
"app": {
"features": ["analytics"],
"analytics": {
"enabled": true
}
}
}"#;
// Test merging logic
// Expected: features should be merged into ["basic", "analytics"]
Ok(())
}
#[test]
fn test_env_variable_integration() -> Result<()> {
let temp_project = crate::create_test_project()?;
let project_root = temp_project.path();
// Test .env file integration
let initial_env = "APP_NAME=test-app\nDEBUG=true\n";
let env_path = project_root.join(".env");
fs::write(&env_path, initial_env)?;
// Simulate adding feature environment variables
// This would use EnvironmentIntegrator
// Verify no duplicates and proper formatting
let final_content = fs::read_to_string(&env_path)?;
assert!(final_content.contains("APP_NAME=test-app"));
assert!(final_content.contains("DEBUG=true"));
Ok(())
}