feat: add production build and health tooling

This commit is contained in:
OpenClaw Agent
2026-09-22 03:19:46 +08:00
parent de01ce2438
commit cd15e34961
8 changed files with 119 additions and 0 deletions
+20
View File
@@ -33,3 +33,23 @@ func TestRootEscapesPlainNotice(t *testing.T) {
t.Fatal("plain notice was not escaped")
}
}
func TestHealthz(t *testing.T) {
s := &Server{}
old := Version
Version = "test"
defer func() { Version = old }()
rr := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/healthz", nil)
s.Handler().ServeHTTP(rr, req)
if rr.Code != http.StatusOK {
t.Fatalf("status=%d body=%s", rr.Code, rr.Body.String())
}
if got := rr.Header().Get("Cache-Control"); got != "no-store" {
t.Fatalf("cache-control=%q", got)
}
if !strings.Contains(rr.Body.String(), `"status":"ok"`) || !strings.Contains(rr.Body.String(), `"version":"test"`) {
t.Fatalf("unexpected body=%s", rr.Body.String())
}
}