mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
test(coderd/x/chatd): avoid zero-ttl config cache flake (#23762)
This fixes a flaky `TestConfigCache_UserPrompt_ExpiredEntryRefetches` by making the seeded user prompt entry unambiguously expired before the cache lookup runs. The test previously inserted a `tlru` entry with a zero TTL, which depends on `Set` and `Get` landing in different clock ticks. Switching that seed entry to a negative TTL keeps the bounded `tlru` cache behavior while removing the same-tick race. Close https://github.com/coder/internal/issues/1432
This commit is contained in:
@@ -278,7 +278,7 @@ func TestConfigCache_UserPrompt_ExpiredEntryRefetches(t *testing.T) {
|
||||
return fmt.Sprintf("prompt-%d", call), nil
|
||||
}
|
||||
cache := newChatConfigCache(ctx, store, clock)
|
||||
cache.userPrompts.Set(userID, "stale", 0)
|
||||
cache.userPrompts.Set(userID, "stale", -time.Second)
|
||||
|
||||
first, err := cache.UserPrompt(ctx, userID)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user