fix: 修复写队列 busy 恢复、关闭安全、备份与配置构建问题

This commit is contained in:
Nixevol
2026-09-30 15:06:11 +08:00
parent 4059a1576b
commit b6908cfba4
23 changed files with 825 additions and 101 deletions
+31
View File
@@ -54,3 +54,34 @@ func TestCmdHealthcheckOK(t *testing.T) {
t.Fatal(err)
}
}
func TestCmdHealthcheckHTTPS(t *testing.T) {
srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))
}))
t.Cleanup(srv.Close)
dir := t.TempDir()
hostPort := srv.Listener.Addr().String()
if err := os.WriteFile(filepath.Join(dir, "listen.addr"), []byte(hostPort+"\n"), 0o644); err != nil {
t.Fatal(err)
}
cert := filepath.Join(dir, "cert.pem")
key := filepath.Join(dir, "key.pem")
if err := os.WriteFile(cert, []byte("dummy"), 0o644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(key, []byte("dummy"), 0o644); err != nil {
t.Fatal(err)
}
cfgPath := filepath.Join(dir, "config.yaml")
body := "listen: \":0\"\ndata_dir: \"" + filepath.ToSlash(dir) + "\"\ntls:\n cert_file: \"" + filepath.ToSlash(cert) + "\"\n key_file: \"" + filepath.ToSlash(key) + "\"\n allow_plaintext: false\n"
if err := os.WriteFile(cfgPath, []byte(body), 0o644); err != nil {
t.Fatal(err)
}
t.Setenv("NIXMSG_CONFIG", cfgPath)
if err := cmdHealthcheck(nil); err != nil {
t.Fatal(err)
}
}