@@ -238,8 +238,10 @@ def test_forward_compatibility
238
238
@old_store = lookup_store
239
239
ActiveSupport ::Cache . format_version = previous_format
240
240
241
- @old_store . write ( "foo" , "bar" )
242
- assert_equal "bar" , @cache . read ( "foo" )
241
+ key = SecureRandom . uuid
242
+ value = SecureRandom . alphanumeric
243
+ @old_store . write ( key , value )
244
+ assert_equal value , @cache . read ( key )
243
245
end
244
246
245
247
def test_backward_compatibility
@@ -248,8 +250,10 @@ def test_backward_compatibility
248
250
@old_store = lookup_store
249
251
ActiveSupport ::Cache . format_version = previous_format
250
252
251
- @cache . write ( "foo" , "bar" )
252
- assert_equal "bar" , @old_store . read ( "foo" )
253
+ key = SecureRandom . uuid
254
+ value = SecureRandom . alphanumeric
255
+ @cache . write ( key , value )
256
+ assert_equal value , @old_store . read ( key )
253
257
end
254
258
255
259
def after_teardown
@@ -363,11 +367,15 @@ def emulating_unavailability
363
367
364
368
class DeleteMatchedTest < StoreTest
365
369
test "deletes keys matching glob" do
366
- @cache . write ( "foo" , "bar" )
367
- @cache . write ( "fu" , "baz" )
368
- @cache . delete_matched ( "foo*" )
369
- assert_not @cache . exist? ( "foo" )
370
- assert @cache . exist? ( "fu" )
370
+ prefix = SecureRandom . alphanumeric
371
+ key = "#{ prefix } #{ SecureRandom . uuid } "
372
+ @cache . write ( key , "bar" )
373
+
374
+ other_key = SecureRandom . uuid
375
+ @cache . write ( other_key , SecureRandom . alphanumeric )
376
+ @cache . delete_matched ( "#{ prefix } *" )
377
+ assert_not @cache . exist? ( key )
378
+ assert @cache . exist? ( other_key )
371
379
end
372
380
373
381
test "fails with regexp matchers" do
@@ -379,19 +387,26 @@ class DeleteMatchedTest < StoreTest
379
387
380
388
class ClearTest < StoreTest
381
389
test "clear all cache key" do
382
- @cache . write ( "foo" , "bar" )
383
- @cache . write ( "fu" , "baz" )
390
+ key = SecureRandom . uuid
391
+ other_key = SecureRandom . uuid
392
+ @cache . write ( key , SecureRandom . uuid )
393
+ @cache . write ( other_key , SecureRandom . uuid )
384
394
@cache . clear
385
- assert_not @cache . exist? ( "foo" )
386
- assert_not @cache . exist? ( "fu" )
395
+ assert_not @cache . exist? ( key )
396
+ assert_not @cache . exist? ( other_key )
387
397
end
388
398
389
399
test "only clear namespace cache key" do
390
- @cache . write ( "foo" , "bar" )
391
- @cache . redis . set ( "fu" , "baz" )
400
+ key = SecureRandom . uuid
401
+ other_key = SecureRandom . uuid
402
+
403
+ @cache . write ( key , SecureRandom . alphanumeric )
404
+ @cache . redis . set ( other_key , SecureRandom . alphanumeric )
392
405
@cache . clear
393
- assert_not @cache . exist? ( "foo" )
394
- assert @cache . redis . exists? ( "fu" )
406
+
407
+ assert_not @cache . exist? ( key )
408
+ assert @cache . redis . exists? ( other_key )
409
+ @cache . redis . del ( other_key )
395
410
end
396
411
397
412
test "clear all cache key with Redis::Distributed" do
0 commit comments