mirror of
https://github.com/openai/codex.git
synced 2026-11-02 00:18:52 +00:00
## Why PR #13783 moved the `codex.rs` unit tests into `codex_tests.rs`. This applies the same extraction pattern across the rest of `codex-rs/core` so the production modules stay focused on runtime code instead of large inline test blocks. Keeping the tests in sibling files also makes follow-up edits easier to review because product changes no longer have to share a file with hundreds or thousands of lines of test scaffolding. ## What changed - replaced each inline `mod tests { ... }` in `codex-rs/core/src/**` with a path-based module declaration - moved each extracted unit test module into a sibling `*_tests.rs` file, using `mod_tests.rs` for `mod.rs` modules - preserved the existing `cfg(...)` guards and module-local structure so the refactor remains structural rather than behavioral ## Testing - `cargo test -p codex-core --lib` (`1653 passed; 0 failed; 5 ignored`) - `just fix -p codex-core` - `cargo fmt --check` - `cargo shear`
69 lines
1.9 KiB
Rust
69 lines
1.9 KiB
Rust
use super::*;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn legacy_landlock_flag_is_included_when_requested() {
|
|
let command = vec!["/bin/true".to_string()];
|
|
let cwd = Path::new("/tmp");
|
|
|
|
let default_bwrap = create_linux_sandbox_command_args(command.clone(), cwd, false, false);
|
|
assert_eq!(
|
|
default_bwrap.contains(&"--use-legacy-landlock".to_string()),
|
|
false
|
|
);
|
|
|
|
let legacy_landlock = create_linux_sandbox_command_args(command, cwd, true, false);
|
|
assert_eq!(
|
|
legacy_landlock.contains(&"--use-legacy-landlock".to_string()),
|
|
true
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn proxy_flag_is_included_when_requested() {
|
|
let command = vec!["/bin/true".to_string()];
|
|
let cwd = Path::new("/tmp");
|
|
|
|
let args = create_linux_sandbox_command_args(command, cwd, true, true);
|
|
assert_eq!(
|
|
args.contains(&"--allow-network-for-proxy".to_string()),
|
|
true
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn split_policy_flags_are_included() {
|
|
let command = vec!["/bin/true".to_string()];
|
|
let cwd = Path::new("/tmp");
|
|
let sandbox_policy = SandboxPolicy::new_read_only_policy();
|
|
let file_system_sandbox_policy = FileSystemSandboxPolicy::from(&sandbox_policy);
|
|
let network_sandbox_policy = NetworkSandboxPolicy::from(&sandbox_policy);
|
|
|
|
let args = create_linux_sandbox_command_args_for_policies(
|
|
command,
|
|
&sandbox_policy,
|
|
&file_system_sandbox_policy,
|
|
network_sandbox_policy,
|
|
cwd,
|
|
true,
|
|
false,
|
|
);
|
|
|
|
assert_eq!(
|
|
args.windows(2)
|
|
.any(|window| { window[0] == "--file-system-sandbox-policy" && !window[1].is_empty() }),
|
|
true
|
|
);
|
|
assert_eq!(
|
|
args.windows(2)
|
|
.any(|window| window[0] == "--network-sandbox-policy" && window[1] == "\"restricted\""),
|
|
true
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn proxy_network_requires_managed_requirements() {
|
|
assert_eq!(allow_network_for_proxy(false), false);
|
|
assert_eq!(allow_network_for_proxy(true), true);
|
|
}
|