增加需确认的全新部署流程
默认升级保留 Smail 运行数据;Linux 和 Windows 的全新部署均要求输入确认词,先备份后仅清理 Smail 专属目录,并补充部署策略回归用例。
This commit is contained in:
1 parent
0c4ad939aa
commit
9eabdd2049
4 files changed
+168
-39
No files matched your search
@@ -96,6 +96,29 @@ func TestInstallerManagesProtectedEnvironmentFile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstallerRequiresExplicitFreshReset(t *testing.T) {
|
||||
root := filepath.Clean(filepath.Join("..", "..", ".."))
|
||||
installer, err := os.ReadFile(filepath.Join(root, "deploy", "install-systemd.sh"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
content := string(installer)
|
||||
for _, required := range []string{
|
||||
"--fresh",
|
||||
"确认全新部署 Smail",
|
||||
"cp -a -- \"$runtime_dir/.\" \"$backup_dir/runtime/\"",
|
||||
"find \"$runtime_dir\" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +",
|
||||
"systemctl disable smail smail-admin",
|
||||
} {
|
||||
if !strings.Contains(content, required) {
|
||||
t.Fatalf("installer is missing explicit fresh-reset behavior %q", required)
|
||||
}
|
||||
}
|
||||
if strings.Contains(content, "全新部署已停止:$target 非空") {
|
||||
t.Fatal("installer must not reject existing data without an explicit fresh-reset request")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSmailServiceRetainsPluginIsolationCapabilities(t *testing.T) {
|
||||
root := filepath.Clean(filepath.Join("..", "..", ".."))
|
||||
unit, err := os.ReadFile(filepath.Join(root, "deploy", "systemd", "smail.service"))
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user