ci / verify (pull_request) Successful in 10m32s
避免恢复任务将已到期的 next_run_at 误插入 River scheduled 状态,并使用专用模型隔离重启集成测试。\n\n验证:Go 全量测试、govulncheck、pnpm lint/test/build/audit、Compose、镜像、迁移、流水线及 SemVer 门禁全部通过。
34 lines
978 B
Go
34 lines
978 B
Go
package runner
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/easyai/easyai-ai-gateway/apps/api/internal/store"
|
|
)
|
|
|
|
func TestAsyncTaskRecoveryInsertOptsMakesDueTaskImmediatelyAvailable(t *testing.T) {
|
|
now := time.Date(2026, time.July, 21, 3, 30, 0, 0, time.UTC)
|
|
opts := asyncTaskRecoveryInsertOpts(store.AsyncTaskQueueItem{
|
|
ID: "due-task",
|
|
NextRunAt: now.Add(-time.Second),
|
|
}, now)
|
|
|
|
if !opts.ScheduledAt.IsZero() {
|
|
t.Fatalf("due recovery task should be immediately available, scheduled at %s", opts.ScheduledAt)
|
|
}
|
|
}
|
|
|
|
func TestAsyncTaskRecoveryInsertOptsPreservesFutureDelay(t *testing.T) {
|
|
now := time.Date(2026, time.July, 21, 3, 30, 0, 0, time.UTC)
|
|
nextRunAt := now.Add(30 * time.Second)
|
|
opts := asyncTaskRecoveryInsertOpts(store.AsyncTaskQueueItem{
|
|
ID: "delayed-task",
|
|
NextRunAt: nextRunAt,
|
|
}, now)
|
|
|
|
if !opts.ScheduledAt.Equal(nextRunAt) {
|
|
t.Fatalf("future recovery task should stay delayed until %s, got %s", nextRunAt, opts.ScheduledAt)
|
|
}
|
|
}
|