Skip to content

Commit

Permalink
Merge pull request redis#197 from matflores/test_saving_with_mock_server
Browse files Browse the repository at this point in the history
Test saving with mock server
  • Loading branch information
pietern committed Mar 14, 2012
2 parents a00e80e + a2e4ed3 commit 38e3f00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
17 changes: 7 additions & 10 deletions test/distributed_persistence_control_commands_test.rb
Expand Up @@ -7,31 +7,28 @@

include RedisMock::Helper

setup do
log = StringIO.new
init Redis::Distributed.new(NODES, :logger => ::Logger.new(log))
end
MOCK_NODES = ["redis://127.0.0.1:6380/15"]

test "SAVE" do
redis_mock(:save => lambda { "+SAVE" }) do
redis = Redis.new(OPTIONS.merge(:port => 6380))
redis = Redis::Distributed.new(MOCK_NODES)

assert "SAVE" == redis.save
assert ["SAVE"] == redis.save
end
end

test "BGSAVE" do
redis_mock(:bgsave => lambda { "+BGSAVE" }) do
redis = Redis.new(OPTIONS.merge(:port => 6380))
redis = Redis::Distributed.new(MOCK_NODES)

assert "BGSAVE" == redis.bgsave
assert ["BGSAVE"] == redis.bgsave
end
end

test "LASTSAVE" do |r|
redis_mock(:lastsave => lambda { "+LASTSAVE" }) do
redis = Redis.new(OPTIONS.merge(:port => 6380))
redis = Redis::Distributed.new(MOCK_NODES)

assert "LASTSAVE" == redis.lastsave
assert ["LASTSAVE"] == redis.lastsave
end
end
6 changes: 1 addition & 5 deletions test/persistence_control_commands_test.rb
Expand Up @@ -5,10 +5,6 @@

include RedisMock::Helper

setup do
init Redis.new(OPTIONS)
end

test "SAVE" do
redis_mock(:save => lambda { "+SAVE" }) do
redis = Redis.new(OPTIONS.merge(:port => 6380))
Expand All @@ -25,7 +21,7 @@
end
end

test "LASTSAVE" do |r|
test "LASTSAVE" do
redis_mock(:lastsave => lambda { "+LASTSAVE" }) do
redis = Redis.new(OPTIONS.merge(:port => 6380))

Expand Down

0 comments on commit 38e3f00

Please sign in to comment.