resque / resque-scheduler

A light-weight job scheduling system built on top of Resque
MIT License
1.74k stars 480 forks source link

Test: Running test destroys my local Redis data #755

Open mishina2228 opened 1 year ago

mishina2228 commented 1 year ago

This project uses Redis on localhost:6379 for testing now. But I use it in the development of other Rails app as well. I was wondering why the data disappeared for a while, but it was due to the following part: https://github.com/resque/resque-scheduler/blob/a9bbbd91879fae12eefffa61d472806210f1a06e/test/delayed_queue_test.rb#L5-L8

I checked what they are doing in Resque and they have Redis on localhost:9736 for testing. https://github.com/resque/resque/blob/daf45bbbaf87411d27c0eb1df44ce463746cf5c8/test/test_helper.rb#L32-L33

# start our own redis when the tests start,
# kill it when they end

https://github.com/resque/resque/blob/daf45bbbaf87411d27c0eb1df44ce463746cf5c8/test/test_helper.rb#L73-L75

  puts "Starting redis for testing at localhost:9736..."
  `redis-server #{$dir}/redis-test.conf`
  Resque.redis = 'localhost:9736'

I think it is a good idea to take this same approach.