mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(upgrade): don't prompt if latest version is older than current binary (#16464)
This commit is contained in:
parent
5cd82b84bb
commit
d1d42e6ba7
1 changed files with 29 additions and 0 deletions
|
@ -123,6 +123,14 @@ impl<TEnvironment: UpdateCheckerEnvironment> UpdateChecker<TEnvironment> {
|
|||
return None;
|
||||
}
|
||||
|
||||
if let Ok(current) = semver::Version::parse(&self.env.current_version()) {
|
||||
if let Ok(latest) = semver::Version::parse(&file.latest_version) {
|
||||
if current >= latest {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let last_prompt_age = self
|
||||
.env
|
||||
.current_time()
|
||||
|
@ -770,4 +778,25 @@ mod test {
|
|||
assert!(checker.should_check_for_new_version());
|
||||
assert_eq!(checker.should_prompt(), None);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_update_checker_current_newer_than_latest() {
|
||||
let env = TestUpdateCheckerEnvironment::new();
|
||||
let file_content = CheckVersionFile {
|
||||
last_prompt: env
|
||||
.current_time()
|
||||
.sub(chrono::Duration::hours(UPGRADE_CHECK_INTERVAL + 1)),
|
||||
last_checked: env.current_time(),
|
||||
latest_version: "1.26.2".to_string(),
|
||||
}
|
||||
.serialize();
|
||||
env.write_check_file(&file_content);
|
||||
env.set_current_version("1.27.0");
|
||||
env.set_latest_version("1.26.2");
|
||||
let checker = UpdateChecker::new(env);
|
||||
|
||||
// since currently running version is newer than latest available (eg. CDN
|
||||
// propagation might be delated) we should not prompt
|
||||
assert_eq!(checker.should_prompt(), None);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue