0.1.38 gateway

This commit is contained in:
ponzischeme89
2026-08-14 09:40:03 +12:00
parent abc392d30b
commit 5e2ed3d12e
2847 changed files with 1072928 additions and 3783 deletions
+18
View File
@@ -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.