-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
During test runs I namespace all Redis operations under "test:* using the redis-namespace Gem. Let's check to see if it works if I configure only: ["test*"]:
$ redis-cli set 'foo' 'bar'
OK
$ redis-cli keys '*'
1) "foo"
$ bin/rspec path/to/spec
# ASSUME TESTS RUN...
$ redis-cli keys '*'
(empty array)Uh oh! We've accidentally wiped every single key in the Redis DB. This is a bummer for my development environment.
I've tracked this down to this bit of code:
database_cleaner-redis/lib/database_cleaner/redis/deletion.rb
Lines 26 to 29 in e8389c2
| only = expand_keys(@only) | |
| except = expand_keys(@except) | |
| only = connection.keys if only.none? | |
| (only - except) |
- On L26 we don't find any keys in the
"test:*"namespace as expected. Ergoonly == [] except:isn't configured, ergoexcept == []only.none?istrue, therefore we go ahead and find all keys in the Redis DB (bug!!)(only - except)returns every single key in the Redis DB, and they're then dutifully wiped out
A reproduction PR: #13
I was hoping we could simply drop L28 but it seems like there's existing behaviour that relies upon this logic.
Metadata
Metadata
Assignees
Labels
No labels