mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Test session index thread-name append and removal (#49959)
## What changed Add a test that appends an original and updated name for one thread alongside another thread's entry. Verify that lookup returns the updated name and that removing the first thread's name entries leaves only the other thread's entry. GitOrigin-RevId: cedf260a639f0c0e76aeda0d446559c3821bd911
This commit is contained in:
@@ -356,6 +356,43 @@ async fn reverse_lookup_accepts_valid_eof_json_and_skips_invalid() -> std::io::R
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn append_and_remove_thread_names_preserves_other_entries() -> std::io::Result<()> {
|
||||
let temp = TempDir::new()?;
|
||||
let removed_id = ThreadId::new();
|
||||
let retained = SessionIndexEntry {
|
||||
id: ThreadId::new(),
|
||||
thread_name: "retained".to_string(),
|
||||
updated_at: "2024-01-01T00:00:00Z".to_string(),
|
||||
};
|
||||
for entry in [
|
||||
SessionIndexEntry {
|
||||
id: removed_id,
|
||||
thread_name: "original".to_string(),
|
||||
..retained.clone()
|
||||
},
|
||||
retained.clone(),
|
||||
SessionIndexEntry {
|
||||
id: removed_id,
|
||||
thread_name: "renamed".to_string(),
|
||||
..retained.clone()
|
||||
},
|
||||
] {
|
||||
append_session_index_entry(temp.path(), entry).await?;
|
||||
}
|
||||
assert_eq!(
|
||||
find_thread_name_by_id(temp.path(), &removed_id).await?,
|
||||
Some("renamed".to_string()),
|
||||
);
|
||||
|
||||
remove_thread_name_entries(temp.path(), removed_id).await?;
|
||||
assert_eq!(
|
||||
std::fs::read_to_string(session_index_path(temp.path()))?,
|
||||
format!("{}\n", serde_json::to_string(&retained)?),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn find_thread_names_by_ids_prefers_latest_entry() -> std::io::Result<()> {
|
||||
let temp = TempDir::new()?;
|
||||
|
||||
Reference in New Issue
Block a user