Add pause resume and abort controls

This commit is contained in:
Mikei386
2026-06-14 22:34:22 +02:00
parent 82d00bd116
commit 656d569b27
13 changed files with 228 additions and 11 deletions
+31
View File
@@ -59,3 +59,34 @@ func TestClearHistoryKeepsActiveAndPendingRuns(t *testing.T) {
q.Stop()
close(release)
}
func TestPauseAndResumeActiveRun(t *testing.T) {
started := make(chan struct{})
release := make(chan struct{})
q := New(func(_ context.Context, run model.Run) model.Run {
close(started)
<-release
run.Status = "success"
return run
}, nil)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go q.Run(ctx)
if err := q.Enqueue(model.Run{ID: "run", JobID: "job"}); err != nil {
t.Fatal(err)
}
<-started
if !q.SetPaused("run", true) {
t.Fatal("active run could not be paused")
}
if runs := q.Snapshot(); len(runs) != 1 || runs[0].Status != "paused" {
t.Fatalf("paused runs = %#v", runs)
}
if !q.SetPaused("run", false) {
t.Fatal("paused run could not be resumed")
}
if runs := q.Snapshot(); len(runs) != 1 || runs[0].Status != "running" {
t.Fatalf("resumed runs = %#v", runs)
}
close(release)
}