mirror of
https://github.com/openai/codex.git
synced 2026-05-17 09:43:19 +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`
44 lines
1.4 KiB
Rust
44 lines
1.4 KiB
Rust
use super::build_commit_message_trailer;
|
|
use super::commit_message_trailer_instruction;
|
|
use super::resolve_attribution_value;
|
|
|
|
#[test]
|
|
fn blank_attribution_disables_trailer_prompt() {
|
|
assert_eq!(build_commit_message_trailer(Some("")), None);
|
|
assert_eq!(commit_message_trailer_instruction(Some(" ")), None);
|
|
}
|
|
|
|
#[test]
|
|
fn default_attribution_uses_codex_trailer() {
|
|
assert_eq!(
|
|
build_commit_message_trailer(None).as_deref(),
|
|
Some("Co-authored-by: Codex <noreply@openai.com>")
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn resolve_value_handles_default_custom_and_blank() {
|
|
assert_eq!(
|
|
resolve_attribution_value(None),
|
|
Some("Codex <noreply@openai.com>".to_string())
|
|
);
|
|
assert_eq!(
|
|
resolve_attribution_value(Some("MyAgent <me@example.com>")),
|
|
Some("MyAgent <me@example.com>".to_string())
|
|
);
|
|
assert_eq!(
|
|
resolve_attribution_value(Some("MyAgent")),
|
|
Some("MyAgent".to_string())
|
|
);
|
|
assert_eq!(resolve_attribution_value(Some(" ")), None);
|
|
}
|
|
|
|
#[test]
|
|
fn instruction_mentions_trailer_and_omits_generated_with() {
|
|
let instruction = commit_message_trailer_instruction(Some("AgentX <agent@example.com>"))
|
|
.expect("instruction expected");
|
|
assert!(instruction.contains("Co-authored-by: AgentX <agent@example.com>"));
|
|
assert!(instruction.contains("exactly once"));
|
|
assert!(!instruction.contains("Generated-with"));
|
|
}
|