feat: add production build and health tooling
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user