Server changes/Sonarr
This commit is contained in:
@@ -97,6 +97,28 @@ func TestHealthAndAdminStayReachableDuringMaintenance(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceStatusReportsMaintenanceOutsideTheGate(t *testing.T) {
|
||||
server := testServer(config.Config{})
|
||||
server.maintenance.set(store.Maintenance{Enabled: true, Message: "Back after dinner"})
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
server.handleServiceStatus(
|
||||
rec,
|
||||
httptest.NewRequest(http.MethodGet, "/v1/status", nil),
|
||||
store.Session{},
|
||||
)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status endpoint returned %d", rec.Code)
|
||||
}
|
||||
var body map[string]any
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["maintenance"] != true || body["message"] != "Back after dinner" {
|
||||
t.Fatalf("unexpected status response: %v", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdminIsDisabledWithoutAToken(t *testing.T) {
|
||||
server := testServer(config.Config{})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user