Skip to content

Test: Running test destroys my local Redis data #755

Open
@mishina2228

Description

@mishina2228

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:

setup do
Resque::Scheduler.quiet = true
Resque.data_store.redis.flushall
end

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions