From 093e799716495ef69bea007d409d779ade73e19f Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Wed, 28 Jan 2026 22:23:56 +0000 Subject: [PATCH] Move integration tests to tests/ directory Session 5 of Wave 4 architecture refactor. - Create src/lib.rs to expose config module for integration tests - Move config integration tests from main.rs to tests/config_integration.rs - Add lib target to Cargo.toml Final main.rs: 328 lines (down from 588, 44% reduction!) Total tests: 16 (14 unit + 2 integration) Wave 4 complete! Co-Authored-By: Claude Opus 4.5 --- Cargo.toml | 4 ++++ src/lib.rs | 5 +++++ src/main.rs | 32 ------------------------------- tests/config_integration.rs | 38 +++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 src/lib.rs create mode 100644 tests/config_integration.rs diff --git a/Cargo.toml b/Cargo.toml index 43b3dab..b2920b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,10 @@ name = "rust4d" version = "0.1.0" edition = "2021" +[lib] +name = "rust4d" +path = "src/lib.rs" + [[bin]] name = "rust4d" path = "src/main.rs" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..711814e --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,5 @@ +//! Rust4D - 4D Rendering Engine +//! +//! This library module exports the configuration system for integration tests. + +pub mod config; diff --git a/src/main.rs b/src/main.rs index d4c0e35..1dc0ccf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -326,35 +326,3 @@ fn main() { let mut app = App::new(); event_loop.run_app(&mut app).expect("Event loop error"); } - -#[cfg(test)] -mod integration_tests { - use super::config::AppConfig; - use serial_test::serial; - - #[test] - #[serial] - fn test_env_override() { - std::env::set_var("R4D_WINDOW__TITLE", "Test From Env"); - let config = AppConfig::load().unwrap(); - println!("Window title: {}", config.window.title); - assert_eq!(config.window.title, "Test From Env"); - std::env::remove_var("R4D_WINDOW__TITLE"); - } - - #[test] - #[serial] - fn test_user_config_loading() { - // Remove env var to test file-based config - std::env::remove_var("R4D_WINDOW__TITLE"); - - // Debug: print current dir and check if files exist - let cwd = std::env::current_dir().unwrap(); - println!("Current dir: {:?}", cwd); - println!("config/default.toml exists: {}", cwd.join("config/default.toml").exists()); - println!("config/user.toml exists: {}", cwd.join("config/user.toml").exists()); - - let config = AppConfig::load().unwrap(); - println!("Window title from file: {}", config.window.title); - } -} diff --git a/tests/config_integration.rs b/tests/config_integration.rs new file mode 100644 index 0000000..857d01b --- /dev/null +++ b/tests/config_integration.rs @@ -0,0 +1,38 @@ +//! Integration tests for configuration loading +//! +//! Tests that verify config loading from files and environment variables. + +use rust4d::config::AppConfig; +use serial_test::serial; + +#[test] +#[serial] +fn test_env_override() { + std::env::set_var("R4D_WINDOW__TITLE", "Test From Env"); + let config = AppConfig::load().unwrap(); + println!("Window title: {}", config.window.title); + assert_eq!(config.window.title, "Test From Env"); + std::env::remove_var("R4D_WINDOW__TITLE"); +} + +#[test] +#[serial] +fn test_user_config_loading() { + // Remove env var to test file-based config + std::env::remove_var("R4D_WINDOW__TITLE"); + + // Debug: print current dir and check if files exist + let cwd = std::env::current_dir().unwrap(); + println!("Current dir: {:?}", cwd); + println!( + "config/default.toml exists: {}", + cwd.join("config/default.toml").exists() + ); + println!( + "config/user.toml exists: {}", + cwd.join("config/user.toml").exists() + ); + + let config = AppConfig::load().unwrap(); + println!("Window title from file: {}", config.window.title); +} -- knotmirror 0.0.1