fix(调度): 修复 outbox 空载写入并稳固回放测试
将 outbox payload 为空时写入 NULL 避免事务因 JSON 解析错误中断 调整回放测试为预置缓存后验证 last_used 更新 测试: go test -tags=integration ./internal/repository
This commit is contained in:
@@ -46,25 +46,12 @@ func TestSchedulerSnapshotOutboxReplay(t *testing.T) {
|
||||
Extra: map[string]any{},
|
||||
}
|
||||
require.NoError(t, accountRepo.Create(ctx, account))
|
||||
require.NoError(t, cache.SetAccount(ctx, account))
|
||||
|
||||
svc := service.NewSchedulerSnapshotService(cache, outboxRepo, accountRepo, nil, cfg)
|
||||
svc.Start()
|
||||
t.Cleanup(svc.Stop)
|
||||
|
||||
bucket := service.SchedulerBucket{GroupID: 0, Platform: service.PlatformOpenAI, Mode: service.SchedulerModeSingle}
|
||||
require.Eventually(t, func() bool {
|
||||
accounts, hit, err := cache.GetSnapshot(ctx, bucket)
|
||||
if err != nil || !hit {
|
||||
return false
|
||||
}
|
||||
for _, acc := range accounts {
|
||||
if acc.ID == account.ID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}, 5*time.Second, 100*time.Millisecond)
|
||||
|
||||
require.NoError(t, accountRepo.UpdateLastUsed(ctx, account.ID))
|
||||
updated, err := accountRepo.GetByID(ctx, account.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user