Skip to content

Commit ad9e1c9

Browse files
committed
test(core): cover custom model array config
1 parent c947de7 commit ad9e1c9

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

codex-rs/core/src/config/config_tests.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,48 @@ consolidation_model = "gpt-5"
151151
);
152152
}
153153

154+
#[test]
155+
fn config_toml_deserializes_custom_models() {
156+
let custom_models = r#"
157+
[[custom_models]]
158+
name = "gpt-5.4 1m"
159+
model = "gpt-5.4"
160+
model_context_window = 1000000
161+
model_auto_compact_token_limit = 900000
162+
"#;
163+
let custom_models_cfg = toml::from_str::<ConfigToml>(custom_models)
164+
.expect("TOML deserialization should succeed for custom models");
165+
166+
assert_eq!(
167+
custom_models_cfg.custom_models,
168+
vec![CustomModelToml {
169+
name: "gpt-5.4 1m".to_string(),
170+
model: "gpt-5.4".to_string(),
171+
model_context_window: Some(1_000_000),
172+
model_auto_compact_token_limit: Some(900_000),
173+
}]
174+
);
175+
176+
let config = Config::load_from_base_config_with_overrides(
177+
custom_models_cfg,
178+
ConfigOverrides::default(),
179+
tempdir().expect("tempdir").path().to_path_buf(),
180+
)
181+
.expect("load config from custom models settings");
182+
183+
assert_eq!(
184+
config.custom_models,
185+
HashMap::from([(
186+
"gpt-5.4 1m".to_string(),
187+
CustomModelConfig {
188+
model: "gpt-5.4".to_string(),
189+
model_context_window: Some(1_000_000),
190+
model_auto_compact_token_limit: Some(900_000),
191+
},
192+
)])
193+
);
194+
}
195+
154196
#[test]
155197
fn config_toml_deserializes_model_availability_nux() {
156198
let toml = r#"

0 commit comments

Comments
 (0)