Files
warpbox-dev/backend/libs/handlers/health_test.go
Daniel Legt 6c87187c6d
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m44s
refactor(api): consolidate health check endpoints to /health
Removes the redundant `/healthz` and `/api/v1/health` endpoints, leaving `/health` as the sole health check endpoint.

- Update router to return 404 Not Found for the removed endpoints
- Update admin log filtering to only ignore `/health`
- Remove health URL from API documentation data
- Update tests to verify `/health` returns 200 and others return 404
- Update README documentation to reflect the change
2026-06-02 11:54:38 +03:00

33 lines
775 B
Go

package handlers
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestHealthRoutes(t *testing.T) {
app, cleanup := newTestApp(t)
defer cleanup()
mux := http.NewServeMux()
app.RegisterRoutes(mux)
request := httptest.NewRequest(http.MethodGet, "/health", nil)
response := httptest.NewRecorder()
mux.ServeHTTP(response, request)
if response.Code != http.StatusOK {
t.Fatalf("status = %d, body = %s", response.Code, response.Body.String())
}
for _, path := range []string{"/healthz", "/api/v1/health"} {
request := httptest.NewRequest(http.MethodGet, path, nil)
response := httptest.NewRecorder()
mux.ServeHTTP(response, request)
if response.Code != http.StatusNotFound {
t.Fatalf("%s status = %d, want 404", path, response.Code)
}
}
}