mirror of
https://github.com/openai/codex.git
synced 2026-04-29 00:55:38 +00:00
## Why `codex-rs/exec/src/lib.rs` already keeps unit tests in a sibling `lib_tests.rs` module so the implementation stays top-heavy and easier to read. This applies that same layout to the rest of `codex-rs/exec/src` so each production file keeps its entry points and helpers ahead of test code. ## What - Move inline unit tests out of `cli.rs`, `main.rs`, `event_processor_with_human_output.rs`, and `event_processor_with_jsonl_output.rs` into sibling `*_tests.rs` files. - Keep test modules wired through `#[cfg(test)]` plus `#[path = "..."] mod tests;`, matching the `lib.rs` pattern. - Preserve the existing test coverage and assertions while making this a source-layout-only refactor. ## Verification - `cargo test -p codex-exec`
38 lines
1.0 KiB
Rust
38 lines
1.0 KiB
Rust
use super::*;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn top_cli_parses_resume_prompt_after_config_flag() {
|
|
const PROMPT: &str = "echo resume-with-global-flags-after-subcommand";
|
|
let cli = TopCli::parse_from([
|
|
"codex-exec",
|
|
"resume",
|
|
"--last",
|
|
"--json",
|
|
"--model",
|
|
"gpt-5.2-codex",
|
|
"--config",
|
|
"reasoning_level=xhigh",
|
|
"--dangerously-bypass-approvals-and-sandbox",
|
|
"--skip-git-repo-check",
|
|
PROMPT,
|
|
]);
|
|
|
|
let Some(codex_exec::Command::Resume(args)) = cli.inner.command else {
|
|
panic!("expected resume command");
|
|
};
|
|
let effective_prompt = args.prompt.clone().or_else(|| {
|
|
if args.last {
|
|
args.session_id.clone()
|
|
} else {
|
|
None
|
|
}
|
|
});
|
|
assert_eq!(effective_prompt.as_deref(), Some(PROMPT));
|
|
assert_eq!(cli.config_overrides.raw_overrides.len(), 1);
|
|
assert_eq!(
|
|
cli.config_overrides.raw_overrides[0],
|
|
"reasoning_level=xhigh"
|
|
);
|
|
}
|