Files
member-console/internal/workflows/schedule_dormancy_test.go
T
cgalo5758 88db730fcc Add dual licensing and SPDX headers
Introduce a commercial license option alongside AGPL-3.0-only, require a
CLA for contributors, and document the terms in COMMERCIAL.md and
NOTICE. Add a script to stamp SPDX headers on Go files and apply it
across the tree.
2026-09-06 02:29:42 -05:00

50 lines
1.8 KiB
Go

// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
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")
}
}