Improve AI provider model configuration
This commit is contained in:
@@ -4,7 +4,7 @@ use std::time::Duration;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn codex_preset_is_version_pinned() {
|
||||
fn codex_preset_uses_the_adapter_with_npx() {
|
||||
let launch = AcpAgentPreset::Codex.launch_config();
|
||||
|
||||
assert_eq!(launch.command, PathBuf::from("npx"));
|
||||
@@ -62,20 +62,28 @@ fn resolved_opencode_prefers_the_native_executable() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolved_codex_falls_back_to_bun_compatibility_mode() {
|
||||
let resolve = |command: &str| (command == "bunx").then(|| PathBuf::from("/opt/bin/bunx"));
|
||||
fn resolved_codex_uses_npx_adapter_and_local_cli() {
|
||||
let resolve = |command: &str| match command {
|
||||
"npx" => Some(PathBuf::from("/opt/bin/npx")),
|
||||
"codex" => Some(PathBuf::from("/opt/homebrew/bin/codex")),
|
||||
_ => None,
|
||||
};
|
||||
let codex = AcpAgentPreset::Codex
|
||||
.resolve_launch_config_with(resolve)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(codex.command, PathBuf::from("/opt/bin/bunx"));
|
||||
assert_eq!(codex.command, PathBuf::from("/opt/bin/npx"));
|
||||
assert_eq!(
|
||||
codex.args,
|
||||
vec![
|
||||
"--bun".to_owned(),
|
||||
"--yes".to_owned(),
|
||||
format!("@agentclientprotocol/codex-acp@{CODEX_ACP_NPM_VERSION}")
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
codex.env.get("CODEX_PATH").map(String::as_str),
|
||||
Some("/opt/homebrew/bin/codex")
|
||||
);
|
||||
assert_eq!(
|
||||
codex.env.get("INITIAL_AGENT_MODE").map(String::as_str),
|
||||
Some("read-only")
|
||||
@@ -89,13 +97,32 @@ fn resolved_codex_falls_back_to_bun_compatibility_mode() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolved_codex_falls_back_to_local_adapter_without_npx() {
|
||||
let resolve = |command: &str| match command {
|
||||
"codex" => Some(PathBuf::from("/opt/homebrew/bin/codex")),
|
||||
"codex-acp" => Some(PathBuf::from("/opt/bin/codex-acp")),
|
||||
_ => None,
|
||||
};
|
||||
let codex = AcpAgentPreset::Codex
|
||||
.resolve_launch_config_with(resolve)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(codex.command, PathBuf::from("/opt/bin/codex-acp"));
|
||||
assert!(codex.args.is_empty());
|
||||
assert_eq!(
|
||||
codex.env.get("CODEX_PATH").map(String::as_str),
|
||||
Some("/opt/homebrew/bin/codex")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolved_presets_explain_missing_launchers() {
|
||||
let error = AcpAgentPreset::Codex
|
||||
.resolve_launch_config_with(|_| None)
|
||||
.unwrap_err();
|
||||
|
||||
assert!(error.contains("requires npx or bunx"));
|
||||
assert!(error.contains("requires the locally installed codex CLI"));
|
||||
|
||||
let opencode_error = AcpAgentPreset::OpenCode
|
||||
.resolve_launch_config_with(|command| {
|
||||
@@ -103,6 +130,13 @@ fn resolved_presets_explain_missing_launchers() {
|
||||
})
|
||||
.unwrap_err();
|
||||
assert!(opencode_error.contains("requires the opencode executable or npx"));
|
||||
|
||||
let codex_adapter_error = AcpAgentPreset::Codex
|
||||
.resolve_launch_config_with(|command| {
|
||||
(command == "codex").then(|| PathBuf::from("/opt/homebrew/bin/codex"))
|
||||
})
|
||||
.unwrap_err();
|
||||
assert!(codex_adapter_error.contains("requires either a local codex-acp executable or npx"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user