diff --git a/cache/cache_test.go b/cache/cache_test.go index 9dc9430..872672d 100644 --- a/cache/cache_test.go +++ b/cache/cache_test.go @@ -320,24 +320,18 @@ func TestCache_ConcurrentReads(t *testing.T) { logger := slog.New(slog.NewTextHandler(os.Stdout, nil)) c := New(logger) - // Setup test data + // Setup test data - use legacy hash to avoid slow bcrypt orgID := uuid.New().String() - apiKey := "test-concurrent-key" // gitleaks:allow - hashedKey, err := hash.APIKey(apiKey) - require.NoError(t, err) + userSub := "test-user" org := domain.Organization{ BaseAggregate: eventsourced.BaseAggregateFromString(orgID), Name: "Concurrent Test Org", } c.organizations[orgID] = org - c.apiKeys[apiKeyId(orgID, "test-key")] = domain.APIKey{ - Name: "test-key", - OrganizationId: orgID, - Key: hashedKey, - } + c.users[userSub] = []string{orgID} - // Run concurrent reads (reduced for race detector) + // Run concurrent reads using fast OrganizationsByUser var wg sync.WaitGroup numGoroutines := 20 @@ -345,9 +339,9 @@ func TestCache_ConcurrentReads(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - org := c.OrganizationByAPIKey(apiKey) - assert.NotNil(t, org) - assert.Equal(t, "Concurrent Test Org", org.Name) + orgs := c.OrganizationsByUser(userSub) + assert.NotEmpty(t, orgs) + assert.Equal(t, "Concurrent Test Org", orgs[0].Name) }() }