From 646449ebee99567ee54c45903690089bf3e133a2 Mon Sep 17 00:00:00 2001 From: Rogee Date: Fri, 21 Aug 2026 13:57:19 +0800 Subject: [PATCH] test(autoassignment): stabilize concurrency diagnostics (#75) Co-authored-by: Rogee --- backend/internal/autoassignment/coverage9_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/internal/autoassignment/coverage9_test.go b/backend/internal/autoassignment/coverage9_test.go index deb2bf7c..957626b1 100644 --- a/backend/internal/autoassignment/coverage9_test.go +++ b/backend/internal/autoassignment/coverage9_test.go @@ -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") }