mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-08 15:43:42 +08:00
- 安装更新前先确认关闭当前安装目录下的 GoNavi 实例,并继续执行未保存 SQL 退出保护 - 按可执行文件路径枚举并复核进程身份,优雅关闭超时后再强制终止,避免 PID 复用误杀 - 通过全局维护事件阻止更新期间启动新实例,并由 PowerShell 更新器完成跨权限无空窗交接 - 同步更新前端交互、多语言提示、Wails 绑定及 Windows 发布资产校验
32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package app
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestResolveWindowsUpdateMaintenanceNameUsesInstallDirectoryIdentity(t *testing.T) {
|
|
installDir := t.TempDir()
|
|
first, err := resolveWindowsUpdateMaintenanceName(filepath.Join(installDir, "GoNavi.exe"))
|
|
if err != nil {
|
|
t.Fatalf("resolve first maintenance name: %v", err)
|
|
}
|
|
second, err := resolveWindowsUpdateMaintenanceName(filepath.Join(installDir, "GoNavi-new.exe"))
|
|
if err != nil {
|
|
t.Fatalf("resolve second maintenance name: %v", err)
|
|
}
|
|
if first != second {
|
|
t.Fatalf("same install directory produced different names: %q != %q", first, second)
|
|
}
|
|
other, err := resolveWindowsUpdateMaintenanceName(filepath.Join(t.TempDir(), "GoNavi.exe"))
|
|
if err != nil {
|
|
t.Fatalf("resolve other maintenance name: %v", err)
|
|
}
|
|
if first == other {
|
|
t.Fatalf("different install directories produced the same name: %q", first)
|
|
}
|
|
if len(first) <= len(`Global\GoNavi-Update-`) || first[:len(`Global\GoNavi-Update-`)] != `Global\GoNavi-Update-` {
|
|
t.Fatalf("maintenance name = %q, want Global namespace", first)
|
|
}
|
|
}
|