(t *testing.T, store *RedisRefreshTokenStore)
| 224 | } |
| 225 | |
| 226 | func testClientSideCache(t *testing.T, store *RedisRefreshTokenStore) { |
| 227 | ctx := context.Background() |
| 228 | token := "test-token-cache" |
| 229 | userData := "cache-test-data" |
| 230 | expiry := time.Now().Add(time.Hour) |
| 231 | |
| 232 | // Set token |
| 233 | err := store.Set(ctx, token, userData, expiry) |
| 234 | assert.NoError(t, err, "Set should not return error") |
| 235 | |
| 236 | // First get (should populate cache) |
| 237 | start1 := time.Now() |
| 238 | retrievedData1, err := store.Get(ctx, token) |
| 239 | duration1 := time.Since(start1) |
| 240 | assert.NoError(t, err, "First Get should not return error") |
| 241 | assert.Equal(t, userData, retrievedData1, "First retrieved data should match stored data") |
| 242 | |
| 243 | // Second get (should use cache and be faster) |
| 244 | start2 := time.Now() |
| 245 | retrievedData2, err := store.Get(ctx, token) |
| 246 | duration2 := time.Since(start2) |
| 247 | assert.NoError(t, err, "Second Get should not return error") |
| 248 | assert.Equal(t, userData, retrievedData2, "Second retrieved data should match stored data") |
| 249 | |
| 250 | // Note: Cache performance test might be flaky in CI environments |
| 251 | t.Logf("First get took: %v, Second get took: %v", duration1, duration2) |
| 252 | |
| 253 | // Clean up test data |
| 254 | _ = store.client.Do(ctx, store.client.B().Del().Key(store.buildKey(token)).Build()) |
| 255 | } |
| 256 | |
| 257 | func TestRedisRefreshTokenStore_ConnectionFailure(t *testing.T) { |
| 258 | // Test with invalid Redis configuration |
no test coverage detected
searching dependent graphs…