drop thread state duration tests

This commit is contained in:
Jeremy Rose
2026-05-01 14:45:23 -07:00
parent 3ac5a6a9d9
commit 0206685a78
-90
View File
@@ -463,93 +463,3 @@ impl ThreadStateManager {
.map(|thread_entry| thread_entry.has_connections_watcher.subscribe())
}
}
#[cfg(test)]
mod tests {
use super::*;
use codex_app_server_protocol::CommandAction;
use codex_app_server_protocol::CommandExecutionSource;
use codex_app_server_protocol::TurnStatus;
use codex_utils_absolute_path::AbsolutePathBuf;
use pretty_assertions::assert_eq;
use std::path::PathBuf;
fn test_absolute_path(path: &str) -> AbsolutePathBuf {
AbsolutePathBuf::try_from(PathBuf::from(path)).expect("path must be absolute")
}
#[test]
fn refreshes_running_command_durations_for_live_turns() {
let mut state = ThreadState::default();
state
.running_command_started_at_ms
.insert("exec-call".into(), now_unix_timestamp_ms() - 1_500);
let mut turns = vec![Turn {
id: "turn-1".into(),
items: vec![ThreadItem::CommandExecution {
id: "exec-call".into(),
command: "sleep 100".into(),
cwd: test_absolute_path(if cfg!(windows) { "C:\\tmp" } else { "/tmp" }),
process_id: Some("pid-1".into()),
source: CommandExecutionSource::Agent,
status: CommandExecutionStatus::InProgress,
command_actions: vec![CommandAction::Unknown {
command: "sleep 100".into(),
}],
aggregated_output: None,
exit_code: None,
duration_ms: Some(0),
}],
status: TurnStatus::InProgress,
error: None,
started_at: None,
completed_at: None,
duration_ms: None,
}];
state.refresh_running_command_durations(&mut turns);
let ThreadItem::CommandExecution { duration_ms, .. } = &turns[0].items[0] else {
panic!("expected command execution item");
};
let elapsed = duration_ms.expect("running command duration");
assert!(elapsed >= 1_500, "elapsed duration should include runtime");
}
#[test]
fn leaves_completed_command_duration_unchanged() {
let mut state = ThreadState::default();
state
.running_command_started_at_ms
.insert("exec-call".into(), now_unix_timestamp_ms() - 1_500);
let mut turns = vec![Turn {
id: "turn-1".into(),
items: vec![ThreadItem::CommandExecution {
id: "exec-call".into(),
command: "sleep 100".into(),
cwd: test_absolute_path(if cfg!(windows) { "C:\\tmp" } else { "/tmp" }),
process_id: Some("pid-1".into()),
source: CommandExecutionSource::Agent,
status: CommandExecutionStatus::Completed,
command_actions: vec![CommandAction::Unknown {
command: "sleep 100".into(),
}],
aggregated_output: Some(String::new()),
exit_code: Some(0),
duration_ms: Some(42),
}],
status: TurnStatus::Completed,
error: None,
started_at: None,
completed_at: None,
duration_ms: None,
}];
state.refresh_running_command_durations(&mut turns);
let ThreadItem::CommandExecution { duration_ms, .. } = &turns[0].items[0] else {
panic!("expected command execution item");
};
assert_eq!(*duration_ms, Some(42));
}
}