c28c4f1419
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>
31 lines
1.0 KiB
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|