This commit is contained in:
ponzischeme89
2026-08-17 07:34:23 +12:00
parent 93fb0fd728
commit 36cb1324fd
56 changed files with 1177 additions and 168 deletions
+25
View File
@@ -90,6 +90,31 @@ func TestMaintenanceGateFallsBackToADefaultMessage(t *testing.T) {
}
}
func TestQuietTimeGateBlocksClientWorkWithTheConfiguredMessage(t *testing.T) {
server := testServer(config.Config{})
now := time.Now()
server.quietTime.set(store.QuietTime{
Enabled: true, StartTime: now.Add(-time.Minute).Format("15:04"),
EndTime: now.Add(time.Minute).Format("15:04"), Message: "Sleeping until morning",
})
rec := httptest.NewRecorder()
server.maintenanceGate(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {
t.Fatal("client handler ran during quiet time")
})).ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/v1/home", nil))
if rec.Code != http.StatusServiceUnavailable {
t.Fatalf("quiet-time response = %d, want 503", rec.Code)
}
var body map[string]any
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
t.Fatalf("body: %v", err)
}
if body["quietTime"] != true || body["message"] != "Sleeping until morning" {
t.Fatalf("quiet-time response = %#v", body)
}
}
func TestBareAdminURLRedirectsToTheConsoleRoot(t *testing.T) {
server := testServer(config.Config{AdminToken: "secret"})
rec := httptest.NewRecorder()