mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 00:45:29 +08:00
27 lines
637 B
Go
27 lines
637 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestHealthEndpointsSupportHEAD(t *testing.T) {
|
|
t.Setenv("DS2API_CONFIG_JSON", `{"keys":["k1"],"accounts":[{"email":"u@example.com","password":"p"}]}`)
|
|
t.Setenv("DS2API_ENV_WRITEBACK", "0")
|
|
|
|
app, err := NewApp()
|
|
if err != nil {
|
|
t.Fatalf("NewApp() error: %v", err)
|
|
}
|
|
|
|
for _, path := range []string{"/healthz", "/readyz"} {
|
|
req := httptest.NewRequest(http.MethodHead, path, nil)
|
|
rec := httptest.NewRecorder()
|
|
app.Router.ServeHTTP(rec, req)
|
|
if rec.Code != http.StatusOK {
|
|
t.Fatalf("expected %s HEAD status 200, got %d", path, rec.Code)
|
|
}
|
|
}
|
|
}
|