mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
tests: adapt remote path followups to current APIs
This commit is contained in:
@@ -2516,10 +2516,7 @@ mod tests {
|
||||
model: "gpt-5".to_string(),
|
||||
model_provider: "openai".to_string(),
|
||||
service_tier: None,
|
||||
cwd: codex_utils_path_uri::ApiPathString::from_abs_path(
|
||||
&cwd,
|
||||
codex_utils_path_uri::PathConvention::native(),
|
||||
)?,
|
||||
cwd: codex_utils_path_uri::ApiPathString::from_abs_path(&cwd),
|
||||
runtime_workspace_roots: Vec::new(),
|
||||
instruction_sources: vec![absolute_path("/tmp/AGENTS.md")],
|
||||
approval_policy: v2::AskForApproval::OnFailure,
|
||||
|
||||
@@ -33,6 +33,7 @@ use codex_login::REFRESH_TOKEN_URL_OVERRIDE_ENV_VAR;
|
||||
use codex_protocol::config_types::SERVICE_TIER_DEFAULT_REQUEST_VALUE;
|
||||
use codex_protocol::config_types::TrustLevel;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_utils_path_uri::ApiPathString;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
@@ -235,10 +236,7 @@ async fn thread_start_accepts_absolute_runtime_workspace_roots() -> Result<()> {
|
||||
assert_eq!(response_cwd.as_str(), cwd.to_string_lossy());
|
||||
assert_eq!(
|
||||
runtime_workspace_roots,
|
||||
vec![ApiPathString::from_abs_path(
|
||||
&extra_root.abs(),
|
||||
PathConvention::native(),
|
||||
)?]
|
||||
vec![ApiPathString::from_abs_path(&extra_root.abs())]
|
||||
);
|
||||
|
||||
Ok(())
|
||||
@@ -263,10 +261,7 @@ async fn thread_start_preserves_explicit_root_equal_to_host_fallback_with_select
|
||||
runtime_workspace_roots: Some(vec![explicit_root.clone()]),
|
||||
environments: Some(vec![TurnEnvironmentParams {
|
||||
environment_id: "local".to_string(),
|
||||
cwd: ApiPathString::from_abs_path(
|
||||
&environment_cwd.path().to_path_buf().abs(),
|
||||
PathConvention::native(),
|
||||
)?,
|
||||
cwd: ApiPathString::from_abs_path(&environment_cwd.path().to_path_buf().abs()),
|
||||
}]),
|
||||
..Default::default()
|
||||
})
|
||||
@@ -280,10 +275,7 @@ async fn thread_start_preserves_explicit_root_equal_to_host_fallback_with_select
|
||||
|
||||
assert_eq!(
|
||||
response.runtime_workspace_roots,
|
||||
vec![ApiPathString::from_abs_path(
|
||||
&explicit_root,
|
||||
PathConvention::native(),
|
||||
)?]
|
||||
vec![ApiPathString::from_abs_path(&explicit_root)]
|
||||
);
|
||||
|
||||
Ok(())
|
||||
@@ -325,9 +317,8 @@ async fn thread_start_excludes_profile_workspace_roots_from_runtime_workspace_ro
|
||||
assert_eq!(
|
||||
runtime_workspace_roots,
|
||||
vec![ApiPathString::from_abs_path(
|
||||
&cwd.path().to_path_buf().abs(),
|
||||
PathConvention::native(),
|
||||
)?]
|
||||
&cwd.path().to_path_buf().abs()
|
||||
)]
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -8146,8 +8146,7 @@ async fn turn_context_item_separates_host_and_model_workspace_roots() {
|
||||
current_environment.environment,
|
||||
windows_cwd.clone(),
|
||||
current_environment.shell,
|
||||
)
|
||||
.expect("remote turn environment");
|
||||
);
|
||||
|
||||
let host_workspace_roots = turn_context.config.effective_workspace_roots();
|
||||
let implicit_item = turn_context.to_turn_context_item();
|
||||
|
||||
@@ -433,7 +433,7 @@ impl TurnContext {
|
||||
&& let Some(primary_environment) = self.environments.primary()
|
||||
&& let Some(implicit_workspace_root) = workspace_roots.first_mut()
|
||||
{
|
||||
*implicit_workspace_root = primary_environment.cwd_uri().clone();
|
||||
*implicit_workspace_root = primary_environment.cwd().clone();
|
||||
}
|
||||
|
||||
let mut seen = HashSet::new();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use app_test_support::TestAppServer;
|
||||
use app_test_support::PathBufExt;
|
||||
use app_test_support::create_mock_responses_server_sequence;
|
||||
use app_test_support::to_response;
|
||||
use app_test_support::write_mock_responses_config_toml;
|
||||
@@ -390,7 +391,7 @@ async fn app_server_starts_thread_with_windows_environment_native_cwd() -> Resul
|
||||
Some(r"<cwd>C:\windows</cwd>"),
|
||||
);
|
||||
assert!(environment_context.contains(
|
||||
r"<workspace_roots><root>C:\codex runtime</root></workspace_roots>"
|
||||
r"<workspace_roots><root>C:\windows</root></workspace_roots>"
|
||||
));
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -775,8 +775,7 @@ fn sample_thread_start_response() -> ThreadStartResponse {
|
||||
model: "gpt-5.4".to_string(),
|
||||
model_provider: "openai".to_string(),
|
||||
service_tier: None,
|
||||
cwd: ApiPathString::from_abs_path(&test_path_buf("/tmp").abs(), PathConvention::native())
|
||||
.expect("API cwd"),
|
||||
cwd: ApiPathString::from_abs_path(&test_path_buf("/tmp").abs()),
|
||||
runtime_workspace_roots: Vec::new(),
|
||||
instruction_sources: Vec::new(),
|
||||
approval_policy: codex_app_server_protocol::AskForApproval::OnRequest,
|
||||
|
||||
@@ -1812,12 +1812,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn foreign_runtime_workspace_root_is_rejected_instead_of_projected_onto_the_tui_host() {
|
||||
let (path, convention) = match PathConvention::native() {
|
||||
PathConvention::Posix => (r"C:\workspace", PathConvention::Windows),
|
||||
PathConvention::Windows => ("/workspace", PathConvention::Posix),
|
||||
let path = match PathConvention::native() {
|
||||
PathConvention::Posix => r"C:\workspace",
|
||||
PathConvention::Windows => "/workspace",
|
||||
};
|
||||
let root = ApiPathString::from_native_absolute_path(path, convention)
|
||||
.expect("foreign path should be valid");
|
||||
let root: ApiPathString =
|
||||
serde_json::from_value(serde_json::json!(path)).expect("API path should deserialize");
|
||||
|
||||
assert_eq!(
|
||||
api_path_to_native_runtime_workspace_root(&root),
|
||||
|
||||
Reference in New Issue
Block a user