29 lines
592 B
Go
29 lines
592 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)
|
||
|
|
|
||
|
|
for _, path := range []string{"/health", "/healthz", "/api/v1/health"} {
|
||
|
|
t.Run(path, func(t *testing.T) {
|
||
|
|
request := httptest.NewRequest(http.MethodGet, path, nil)
|
||
|
|
response := httptest.NewRecorder()
|
||
|
|
|
||
|
|
mux.ServeHTTP(response, request)
|
||
|
|
|
||
|
|
if response.Code != http.StatusOK {
|
||
|
|
t.Fatalf("status = %d, body = %s", response.Code, response.Body.String())
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|