Files
codex/codex-rs/windows-sandbox-service/src/main_tests.rs
T
johnl-oai 501931b399 Add Windows sandbox service lifecycle scaffolding (#42341)
## What changed

- Add the `codex-windows-sandbox-service` workspace crate and Windows-only build target.
- Integrate `CodexSandboxService` with the Windows Service Control Manager, including start, stop, shutdown, status reporting, and event-log handling.
- Support service mode by default and a debug-only `--foreground` mode. Keep provisioning IPC disabled until authenticated request handling is available.

## Testing

- Add argument-parsing tests for service, foreground, unknown, and multiple arguments.

GitOrigin-RevId: 1c84f0a593b65e5cf97ab7606cde03675542b0b0
2026-09-02 19:49:58 +00:00

45 lines
1.1 KiB
Rust

use anyhow::Result;
use super::RunMode;
use super::parse_mode;
#[test]
fn defaults_to_service_mode() -> Result<()> {
assert_eq!(parse_mode(std::iter::empty())?, RunMode::Service);
Ok(())
}
#[test]
fn accepts_explicit_service_mode() -> Result<()> {
let arguments = [String::from("--service")].into_iter();
assert_eq!(parse_mode(arguments)?, RunMode::Service);
Ok(())
}
#[test]
#[cfg(debug_assertions)]
fn accepts_foreground_mode() -> Result<()> {
let arguments = [String::from("--foreground")].into_iter();
assert_eq!(parse_mode(arguments)?, RunMode::Foreground);
Ok(())
}
#[test]
#[cfg(not(debug_assertions))]
fn rejects_foreground_mode_in_release_builds() {
let arguments = [String::from("--foreground")].into_iter();
assert!(parse_mode(arguments).is_err());
}
#[test]
fn rejects_unknown_arguments() {
let arguments = [String::from("--unknown")].into_iter();
assert!(parse_mode(arguments).is_err());
}
#[test]
fn rejects_multiple_arguments() {
let arguments = [String::from("--service"), String::from("--foreground")].into_iter();
assert!(parse_mode(arguments).is_err());
}