From abbf0339cd0013ba7d691adf76460631c6a03e9f Mon Sep 17 00:00:00 2001 From: crowlKats <13135287+crowlKats@users.noreply.github.com> Date: Sat, 9 May 2020 12:31:15 +0200 Subject: feat(upgrade): allow specifying a version (#5156) --- cli/tests/integration_tests.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'cli/tests/integration_tests.rs') diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 28df47250..7ad7781de 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -224,6 +224,37 @@ fn upgrade_in_tmpdir() { // TODO(ry) assert!(mtime1 < mtime2); } +// Warning: this test requires internet access. +#[test] +fn upgrade_with_version_in_tmpdir() { + let temp_dir = TempDir::new().unwrap(); + let exe_path = if cfg!(windows) { + temp_dir.path().join("deno") + } else { + temp_dir.path().join("deno.exe") + }; + let _ = std::fs::copy(util::deno_exe_path(), &exe_path).unwrap(); + assert!(exe_path.exists()); + let _mtime1 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); + let status = Command::new(&exe_path) + .arg("upgrade") + .arg("--force") + .arg("--version") + .arg("0.42.0") + .spawn() + .unwrap() + .wait() + .unwrap(); + assert!(status.success()); + let upgraded_deno_version = String::from_utf8( + Command::new(&exe_path).arg("-V").output().unwrap().stdout, + ) + .unwrap(); + assert!(upgraded_deno_version.contains("0.42.0")); + let _mtime2 = std::fs::metadata(&exe_path).unwrap().modified().unwrap(); + // TODO(ry) assert!(mtime1 < mtime2); +} + #[test] fn installer_test_local_module_run() { let temp_dir = TempDir::new().expect("tempdir fail"); -- cgit v1.2.3