From 01c513fcaa99f2de4a31dd78866f30f93029328e Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Tue, 5 May 2026 04:32:32 +0300 Subject: [PATCH] codex: align tests with lenient config enums Update test expectations after invalid enum values no longer fail whole config deserialization. Co-authored-by: Codex --- .../src/config_manager_service_tests.rs | 16 ++++++++-------- codex-rs/core/src/config/config_tests.rs | 10 +++++----- codex-rs/core/src/personality_migration_tests.rs | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/codex-rs/app-server/src/config_manager_service_tests.rs b/codex-rs/app-server/src/config_manager_service_tests.rs index e9b0b3c769..67add1c33f 100644 --- a/codex-rs/app-server/src/config_manager_service_tests.rs +++ b/codex-rs/app-server/src/config_manager_service_tests.rs @@ -455,7 +455,7 @@ async fn write_value_defaults_to_user_config_path() { } #[tokio::test] -async fn invalid_user_value_rejected_even_if_overridden_by_managed() { +async fn invalid_user_value_written_if_overridden_by_managed() { let tmp = tempdir().expect("tempdir"); std::fs::write(tmp.path().join(CONFIG_TOML_FILE), "model = \"user\"").unwrap(); @@ -469,7 +469,7 @@ async fn invalid_user_value_rejected_even_if_overridden_by_managed() { CloudRequirementsLoader::default(), ); - let error = service + let result = service .write_value(ConfigValueWriteParams { file_path: Some(tmp.path().join(CONFIG_TOML_FILE).display().to_string()), key_path: "approval_policy".to_string(), @@ -478,15 +478,15 @@ async fn invalid_user_value_rejected_even_if_overridden_by_managed() { expected_version: None, }) .await - .expect_err("should fail validation"); + .expect("write succeeds because managed config still supplies a valid effective value"); - assert_eq!( - error.write_error_code(), - Some(ConfigWriteErrorCode::ConfigValidationError) - ); + assert_eq!(result.status, WriteStatus::OkOverridden); let contents = std::fs::read_to_string(tmp.path().join(CONFIG_TOML_FILE)).expect("read config"); - assert_eq!(contents.trim(), "model = \"user\""); + assert_eq!( + contents.trim(), + "model = \"user\"\napproval_policy = \"bogus\"" + ); } #[tokio::test] diff --git a/codex-rs/core/src/config/config_tests.rs b/codex-rs/core/src/config/config_tests.rs index 65c4544ccf..f07082d224 100644 --- a/codex-rs/core/src/config/config_tests.rs +++ b/codex-rs/core/src/config/config_tests.rs @@ -3446,7 +3446,7 @@ async fn managed_config_overrides_oauth_store_mode() -> anyhow::Result<()> { assert_eq!( cfg.mcp_oauth_credentials_store .clone() - .and_then(|value| value.into_valid()), + .and_then(codex_config::Lenient::into_valid), Some(OAuthCredentialsStoreMode::Keyring), ); @@ -4573,7 +4573,7 @@ async fn set_model_updates_defaults() -> anyhow::Result<()> { assert_eq!( parsed .model_reasoning_effort - .and_then(|value| value.into_valid()), + .and_then(codex_config::Lenient::into_valid), Some(ReasoningEffort::High) ); @@ -4609,7 +4609,7 @@ model = "gpt-4.1" assert_eq!( parsed .model_reasoning_effort - .and_then(|value| value.into_valid()), + .and_then(codex_config::Lenient::into_valid), Some(ReasoningEffort::High) ); assert_eq!( @@ -4645,7 +4645,7 @@ async fn set_model_updates_profile() -> anyhow::Result<()> { profile .model_reasoning_effort .clone() - .and_then(|value| value.into_valid()), + .and_then(codex_config::Lenient::into_valid), Some(ReasoningEffort::Medium) ); @@ -4688,7 +4688,7 @@ model = "gpt-5.4" dev_profile .model_reasoning_effort .clone() - .and_then(|value| value.into_valid()), + .and_then(codex_config::Lenient::into_valid), Some(ReasoningEffort::Medium) ); diff --git a/codex-rs/core/src/personality_migration_tests.rs b/codex-rs/core/src/personality_migration_tests.rs index a67ca6289b..40efe1104e 100644 --- a/codex-rs/core/src/personality_migration_tests.rs +++ b/codex-rs/core/src/personality_migration_tests.rs @@ -17,7 +17,7 @@ use tokio::io::AsyncWriteExt; const TEST_TIMESTAMP: &str = "2025-01-01T00-00-00"; fn valid_lenient(value: Option>) -> Option { - value.and_then(|value| value.into_valid()) + value.and_then(Lenient::into_valid) } async fn read_config_toml(codex_home: &Path) -> io::Result {