package server_test import ( "net/http" "net/http/httptest" "testing" "cmbuyer/admin/internal/server" ) func TestHealthz(t *testing.T) { request := httptest.NewRequest(http.MethodGet, "/healthz", nil) response := httptest.NewRecorder() server.NewRouter().ServeHTTP(response, request) if response.Code != http.StatusOK { t.Fatalf("healthz status = %d, want %d", response.Code, http.StatusOK) } if contentType := response.Header().Get("Content-Type"); contentType != "application/json; charset=utf-8" { t.Fatalf("healthz content type = %q, want application/json; charset=utf-8", contentType) } if body := response.Body.String(); body != "{\"status\":\"ok\"}" { t.Fatalf("healthz body = %q, want {\"status\":\"ok\"}", body) } }