lesavka/testing/tests/client_main_binary_contract.rs

72 lines
2.4 KiB
Rust
Raw Normal View History

//! Integration coverage for client binary startup wiring.
//!
//! Scope: include `client/src/main.rs` and exercise startup guards/tracing
//! branches without launching the full runtime app loop.
//! Targets: `client/src/main.rs`.
//! Why: keep client startup behavior deterministic and directly attributed to
//! the binary entrypoint source file.
#[allow(clippy::suspicious_open_options)]
mod client_main_binary {
include!(env!("LESAVKA_CLIENT_MAIN_SRC"));
use serial_test::serial;
use temp_env::with_var;
#[test]
#[serial]
fn main_returns_ok_when_test_skip_flag_enabled() {
with_var("LESAVKA_HEADLESS", Some("1"), || {
with_var("LESAVKA_DEV_MODE", None::<&str>, || {
with_var("LESAVKA_TEST_SKIP_APP", Some("1"), || {
let result = main();
assert!(result.is_ok(), "test skip flag should bypass app runtime");
});
});
});
}
#[test]
#[serial]
fn main_dev_mode_branch_initializes_and_returns_when_skipped() {
with_var("LESAVKA_HEADLESS", Some("1"), || {
with_var("LESAVKA_DEV_MODE", Some("1"), || {
with_var("LESAVKA_TEST_SKIP_APP", Some("1"), || {
let result = main();
assert!(
result.is_ok(),
"dev-mode startup should succeed in test skip mode"
);
});
});
});
}
#[test]
#[serial]
fn main_checks_runtime_dir_when_not_headless() {
with_var("LESAVKA_HEADLESS", None::<&str>, || {
with_var("XDG_RUNTIME_DIR", Some("/run/user/1000"), || {
with_var("LESAVKA_DEV_MODE", None::<&str>, || {
with_var("LESAVKA_TEST_SKIP_APP", Some("1"), || {
let result = main();
assert!(result.is_ok(), "runtime-dir path should pass startup guard");
});
});
});
});
}
#[test]
#[serial]
fn ensure_runtime_dir_panics_in_tests_when_missing() {
with_var("XDG_RUNTIME_DIR", None::<&str>, || {
let panic_result = std::panic::catch_unwind(ensure_runtime_dir);
assert!(
panic_result.is_err(),
"missing runtime dir should panic in test cfg"
);
});
}
}