1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(upgrade): don't prompt if latest version is older than current binary (#16464)

This commit is contained in:
Bartek Iwańczuk 2022-10-28 18:43:49 +02:00 committed by GitHub
parent 5cd82b84bb
commit d1d42e6ba7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}
}