Files
member-console/internal/workflows/schedule_dormancy_test.go
T
cgalo5758 30b8250cf5 Pause integration schedules when disabled
Resume only app-paused schedules so operator pauses survive restarts.
Apply dormancy handling to Discourse and FedWiki.

Remove the unused pool-scoped grant route, hide internal transition
errors, and update specs and tests to use the canonical grant endpoint.
2026-07-23 01:38:45 -05:00

47 lines
1.7 KiB
Go

package workflows
import (
"testing"
"go.temporal.io/sdk/client"
)
// The Schedule API has no testsuite fake, so the pause/resume decision
// logic is pinned here as pure functions and the client interaction is
// covered by live boot-sequence verification (see the resolved issue
// "Unconfiguring Discourse leaves its durable sweep schedule firing
// forever" in status/archive/issues-resolved.md).
func TestShouldPauseLeftover(t *testing.T) {
if !shouldPauseLeftover(nil) {
t.Error("nil state (server default: running) must be paused")
}
if !shouldPauseLeftover(&client.ScheduleState{Paused: false}) {
t.Error("running schedule must be paused")
}
if shouldPauseLeftover(&client.ScheduleState{Paused: true, Note: "operator: investigating"}) {
t.Error("already-paused schedule must be left untouched")
}
if shouldPauseLeftover(&client.ScheduleState{Paused: true, Note: DormantPauseNote}) {
t.Error("our own earlier pause must be left untouched (idempotency)")
}
}
func TestShouldResumeDormant(t *testing.T) {
if !shouldResumeDormant(&client.ScheduleState{Paused: true, Note: DormantPauseNote}) {
t.Error("our dormancy pause must resume on a configured boot")
}
if shouldResumeDormant(&client.ScheduleState{Paused: true, Note: "operator: investigating"}) {
t.Error("an operator's pause must survive a configured boot")
}
if shouldResumeDormant(&client.ScheduleState{Paused: true, Note: ""}) {
t.Error("a pause with no note must be treated as operator intent")
}
if shouldResumeDormant(&client.ScheduleState{Paused: false, Note: DormantPauseNote}) {
t.Error("a running schedule needs no resume")
}
if shouldResumeDormant(nil) {
t.Error("nil state needs no resume")
}
}