package server import ( "encoding/json" "io" "log/slog" "net/http" "net/http/httptest" "testing" ) func TestHealthz(t *testing.T) { s := New(slog.New(slog.NewTextHandler(io.Discard, nil)), nil, nil) ts := httptest.NewServer(s.Router()) defer ts.Close() resp, err := http.Get(ts.URL + "/healthz") if err != nil { t.Fatalf("GET /healthz: %v", err) } defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { t.Errorf("status = %d, want 200", resp.StatusCode) } var body map[string]string if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { t.Fatalf("decode: %v", err) } if body["status"] != "ok" { t.Errorf("body = %v, want status=ok", body) } }