package httpapi import ( "encoding/json" "net/http" "net/http/httptest" "testing" ) func TestLiveness(t *testing.T) { w := httptest.NewRecorder() NewRouter().ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/api/v1/health/live", nil)) if w.Code != http.StatusOK { t.Fatalf("status = %d, want 200", w.Code) } var body struct{ Status string `json:"status"` } if err := json.Unmarshal(w.Body.Bytes(), &body); err != nil || body.Status != "ok" { t.Fatalf("body = %q, err = %v", w.Body.String(), err) } } func TestUnknownRoute(t *testing.T) { w := httptest.NewRecorder() NewRouter().ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/api/v1/licenses", nil)) if w.Code != http.StatusNotFound { t.Fatalf("status = %d, want 404", w.Code) } }