Files
codex/codex-rs/tui/src/updates_cache_tests.rs
T
Eric Traut 096e5e76a2 Persist update dismissal without cache (#27783)
## Summary

Choosing “Don’t remind me” can silently fail when `version.json`
disappears before dismissal because `dismiss_version` returns success
without writing anything. The same update can then reappear on the next
launch.

Initialize a minimal `VersionInfo` from the selected version when the
cache cannot be read, then persist the dismissal through the existing
write path.

Fixes #27147
2026-06-12 09:26:08 -07:00

30 lines
870 B
Rust

use super::*;
use crate::legacy_core::config::ConfigBuilder;
use pretty_assertions::assert_eq;
use tempfile::tempdir;
#[tokio::test]
async fn dismiss_version_creates_cache_file_when_missing() {
let codex_home = tempdir().expect("temp codex home");
let config = ConfigBuilder::default()
.codex_home(codex_home.path().to_path_buf())
.build()
.await
.expect("load config");
let version_file = version_filepath(&config);
dismiss_version(&config, "999.0.0")
.await
.expect("dismiss version");
let info = read_version_info(&version_file).expect("read version info");
assert_eq!(info.last_checked_at, DateTime::<Utc>::UNIX_EPOCH);
assert_eq!(
(
info.latest_version.as_str(),
info.dismissed_version.as_deref()
),
("999.0.0", Some("999.0.0"))
);
}