0.1.38 gateway
This commit is contained in:
@@ -22,6 +22,13 @@ func testServer(cfg config.Config) *Server {
|
||||
return New(cfg, Deps{Log: slog.New(slog.NewTextHandler(io.Discard, nil))})
|
||||
}
|
||||
|
||||
func TestStatusRecorderPreservesStreaming(t *testing.T) {
|
||||
recorder := &statusRecorder{ResponseWriter: httptest.NewRecorder()}
|
||||
if _, ok := any(recorder).(http.Flusher); !ok {
|
||||
t.Fatal("logging response writer must preserve http.Flusher for Server-Sent Events")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaintenanceGatePassesTrafficWhenOnline(t *testing.T) {
|
||||
server := testServer(config.Config{})
|
||||
var reached bool
|
||||
@@ -83,6 +90,17 @@ func TestMaintenanceGateFallsBackToADefaultMessage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBareAdminURLRedirectsToTheConsoleRoot(t *testing.T) {
|
||||
server := testServer(config.Config{AdminToken: "secret"})
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
server.Routes().ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/admin", nil))
|
||||
|
||||
if rec.Code != http.StatusFound || rec.Header().Get("Location") != "/admin/" {
|
||||
t.Fatalf("bare admin URL = %d %q, want 302 to /admin/", rec.Code, rec.Header().Get("Location"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthAndAdminStayReachableDuringMaintenance(t *testing.T) {
|
||||
// Health checks and the admin page sit outside the gate on purpose: they are what
|
||||
// you need most while the app is deliberately down.
|
||||
|
||||
Reference in New Issue
Block a user