mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
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
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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"))
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user