From 54738e9e149b694c9c3a699d56fddd2d4fa26a6a Mon Sep 17 00:00:00 2001 From: Ethan <39577870+ethanndickson@users.noreply.github.com> Date: Mon, 30 Mar 2026 17:51:51 +1100 Subject: [PATCH] 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 --- coderd/x/chatd/configcache_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coderd/x/chatd/configcache_test.go b/coderd/x/chatd/configcache_test.go index c99a81d75e..a874eb9512 100644 --- a/coderd/x/chatd/configcache_test.go +++ b/coderd/x/chatd/configcache_test.go @@ -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)