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") } }