增加需确认的全新部署流程

默认升级保留 Smail 运行数据;Linux 和 Windows 的全新部署均要求输入确认词,先备份后仅清理 Smail 专属目录,并补充部署策略回归用例。
This commit is contained in:
xuans committed 2026-10-01 11:48:03 +08:00
1 parent e5d52ed681
commit ca28fa982e
4 files changed
+168 -39

No files matched your search

@@ -50,6 +50,29 @@ func TestWindowsDeploymentScriptsKeepAdminChannelManual(t *testing.T) {
}
}
func TestWindowsInstallerRequiresExplicitFreshReset(t *testing.T) {
root := filepath.Clean(filepath.Join("..", "..", ".."))
installer, err := os.ReadFile(filepath.Join(root, "deploy", "install-windows.ps1"))
if err != nil {
t.Fatal(err)
}
content := string(installer)
for _, required := range []string{
"[switch]$Fresh",
"确认全新部署 Smail",
".smail-fresh-backup-",
"Copy-Item -LiteralPath $item.FullName -Destination (Join-Path $backupRoot $item.Name) -Recurse -Force",
"Remove-Item -LiteralPath $item.FullName -Recurse -Force",
} {
if !strings.Contains(content, required) {
t.Fatalf("Windows installer is missing explicit fresh-reset behavior %q", required)
}
}
if strings.Contains(content, "全新部署已停止:$existing 不是空目录") {
t.Fatal("Windows installer must not reject existing data without an explicit fresh-reset request")
}
}
func hasUTF8BOM(data []byte) bool {
return len(data) >= 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF
}