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>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user