diff --git a/plugins/updater/tests/app-updater/src/main.rs b/plugins/updater/tests/app-updater/src/main.rs index 5f5566f8..d3defc1e 100644 --- a/plugins/updater/tests/app-updater/src/main.rs +++ b/plugins/updater/tests/app-updater/src/main.rs @@ -1,56 +1,57 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] - -use tauri_plugin_updater::UpdaterExt; - -fn main() { - #[allow(unused_mut)] - let mut context = tauri::generate_context!(); - tauri::Builder::default() - .plugin(tauri_plugin_updater::Builder::new().build()) - .setup(|app| { - let handle = app.handle().clone(); - tauri::async_runtime::spawn(async move { - let mut builder = handle.updater_builder(); - if std::env::var("TARGET").unwrap_or_default() == "nsis" { - // /D sets the default installation directory ($INSTDIR), - // overriding InstallDir and InstallDirRegKey. - // It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. - // Only absolute paths are supported. - // NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder - builder = builder.installer_args(vec![format!( - "/D={}", - tauri::utils::platform::current_exe() - .unwrap() - .parent() - .unwrap() - .display() - )]); - } - let updater = builder.build().unwrap(); - - match updater.check().await { - Ok(Some(update)) => { - if let Err(e) = update.download_and_install(|_, _| {}, || {}).await { - println!("{e}"); - std::process::exit(1); - } - std::process::exit(0); - } - Ok(None) => { - std::process::exit(2); - } - Err(e) => { - println!("{e}"); - std::process::exit(1); - } - } - }); - Ok(()) - }) - .run(context) - .expect("error while running tauri application"); -} +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +use tauri_plugin_updater::UpdaterExt; + +fn main() { + #[allow(unused_mut)] + let mut context = tauri::generate_context!(); + println!("{}", tauri::__TAURI_BUNDLE_TYPE); + tauri::Builder::default() + .plugin(tauri_plugin_updater::Builder::new().build()) + .setup(|app| { + let handle = app.handle().clone(); + tauri::async_runtime::spawn(async move { + let mut builder = handle.updater_builder(); + if std::env::var("TARGET").unwrap_or_default() == "nsis" { + // /D sets the default installation directory ($INSTDIR), + // overriding InstallDir and InstallDirRegKey. + // It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. + // Only absolute paths are supported. + // NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder + builder = builder.installer_args(vec![format!( + "/D={}", + tauri::utils::platform::current_exe() + .unwrap() + .parent() + .unwrap() + .display() + )]); + } + let updater = builder.build().unwrap(); + + match updater.check().await { + Ok(Some(update)) => { + if let Err(e) = update.download_and_install(|_, _| {}, || {}).await { + println!("{e}"); + std::process::exit(1); + } + std::process::exit(0); + } + Ok(None) => { + std::process::exit(2); + } + Err(e) => { + println!("{e}"); + std::process::exit(1); + } + } + }); + Ok(()) + }) + .run(context) + .expect("error while running tauri application"); +} diff --git a/plugins/updater/tests/app-updater/tests/update.rs b/plugins/updater/tests/app-updater/tests/update.rs index 8c308bb3..a36ae90e 100644 --- a/plugins/updater/tests/app-updater/tests/update.rs +++ b/plugins/updater/tests/app-updater/tests/update.rs @@ -119,8 +119,11 @@ fn target_to_platforms( update_platform: Option, signature: String, ) -> HashMap { + let mut platforms = HashMap::new(); if let Some(platform) = update_platform { + println!("TARGET: {}", platform.clone()); + platforms.insert( platform, PlatformUpdate { @@ -201,24 +204,60 @@ fn bundle_path(root_dir: &Path, _version: &str, v1compatible: bool) -> PathBuf { } #[cfg(windows)] -fn bundle_paths( +fn test_cases( root_dir: &Path, version: &str, - v1compatible: bool, -) -> Vec<(BundleTarget, PathBuf)> { + target: String +) -> Vec<(BundleTarget, PathBuf, Option, Vec)> { vec![ ( BundleTarget::Nsis, root_dir.join(format!( "target/debug/bundle/nsis/app-updater_{version}_x64-setup.exe" )), + Some(target.clone()), + vec![UPDATED_EXIT_CODE] + ), + ( + BundleTarget::Nsis, + root_dir.join(format!( + "target/debug/bundle/nsis/app-updater_{version}_x64-setup.exe" + )), + Some(format!("{target}-{}", BundleTarget::Nsis.name())), + vec![UPDATED_EXIT_CODE] + ), + ( + BundleTarget::Nsis, + root_dir.join(format!( + "target/debug/bundle/nsis/app-updater_{version}_x64-setup.exe" + )), + None, + vec![ERROR_EXIT_CODE] ), ( BundleTarget::Msi, root_dir.join(format!( "target/debug/bundle/msi/app-updater_{version}_x64_en-US.msi" )), + Some(target.clone()), + vec![UPDATED_EXIT_CODE] ), + ( + BundleTarget::Msi, + root_dir.join(format!( + "target/debug/bundle/msi/app-updater_{version}_x64_en-US.msi" + )), + Some(format!("{target}-{}", BundleTarget::Msi.name())), + vec![UPDATED_EXIT_CODE] + ), + ( + BundleTarget::Msi, + root_dir.join(format!( + "target/debug/bundle/msi/app-updater_{version}_x64_en-US.msi" + )), + None, + vec![ERROR_EXIT_CODE] + ) ] }