Files
tauri-plugins-workspace/plugins/updater/tests/updater-migration/v2-app/src/main.rs
T
Lucas Fernandes Nogueira 7701392500 fix(updater): linux not retaining AppImage permissions, enhance tests (#1636)
* fix(updater): linux not retaining AppImage permissions, enhance tests

- adds a test for migration from v1 to v2
- extends the existing integration test to actually verify if the app was updated

* remove test framework

* fix macos test

* fix windows

* wait on windows

* fix wix

* typo

* fmt

* install webkit2gtk-4.0 on ci

* fix npm command on windows

* fix test on windows

* ubuntu-22.04

---------

Co-authored-by: Tillmann <28728469+tweidinger@users.noreply.github.com>
2024-08-12 14:59:53 -03:00

59 lines
2.4 KiB
Rust

// 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| {
println!("version={}", app.package_info().version);
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");
}