Files
geo/server/internal/scheduler/schedule_dispatch_worker_test.go
T
root c28c4f1419
Frontend CI / Frontend (push) Successful in 3m37s
Backend CI / Backend (push) Failing after 6m47s
feat(schedule): support KOL subscription targets and random time windows
Extend schedule tasks to dispatch KOL subscription prompts in addition
to prompt rules, add daily/weekly scheduling with fixed or random time
windows, and track dispatch outcomes (last run, status, consecutive
failures).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 23:51:45 +08:00

31 lines
1.0 KiB
Go

package scheduler
import "testing"
func TestAggregateDispatchResult(t *testing.T) {
tests := []struct {
name string
generateCount int
failedCount int
wantStatus string
wantFailureCount bool
}{
{name: "all success", generateCount: 3, failedCount: 0, wantStatus: "success"},
{name: "partial success", generateCount: 3, failedCount: 1, wantStatus: "partial"},
{name: "all failed", generateCount: 3, failedCount: 3, wantStatus: "failed", wantFailureCount: true},
{name: "zero generate count defaults to one", generateCount: 0, failedCount: 1, wantStatus: "failed", wantFailureCount: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := aggregateDispatchResult(tt.generateCount, tt.failedCount)
if got.status != tt.wantStatus {
t.Fatalf("status = %q, want %q", got.status, tt.wantStatus)
}
if got.countAsFailure != tt.wantFailureCount {
t.Fatalf("countAsFailure = %v, want %v", got.countAsFailure, tt.wantFailureCount)
}
})
}
}