test(autoassignment): stabilize concurrency diagnostics (#75)
Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -227,9 +227,16 @@ func TestAssignmentServiceOnlyOneConcurrentWorkerWins(t *testing.T) {
|
||||
|
||||
var updated model.Conversation
|
||||
require.NoError(t, db.First(&updated, conversation.ID).Error)
|
||||
require.NotNil(t, updated.AssigneeID, "最终会话必须已分配")
|
||||
require.Equal(t, agent.ID, *updated.AssigneeID)
|
||||
rateCount, err := NewRateLimiter(rdb).GetCount(context.Background(), inbox.ID, agent.ID, 300)
|
||||
rateKeys, err := rdb.Keys(context.Background(), fmt.Sprintf("%s%d:%d:*", rateLimitKeyPrefix, inbox.ID, agent.ID)).Result()
|
||||
require.NoError(t, err)
|
||||
rateCount := 0
|
||||
for _, key := range rateKeys {
|
||||
count, err := rdb.Get(context.Background(), key).Int()
|
||||
require.NoError(t, err)
|
||||
rateCount += count
|
||||
}
|
||||
require.Equal(t, 1, rateCount, "the CAS loser must not increment the rate-limit key")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user