Sha256: 057a6b6023c4135257f6d968fed10e2b858f3622756560fced54e755cd721116
Contents?: true
Size: 1.78 KB
Versions: 2
Compression:
Stored size: 1.78 KB
Contents
# encoding: UTF-8 require File.expand_path("./helper", File.dirname(__FILE__)) require File.expand_path("./redis_mock", File.dirname(__FILE__)) include RedisMock::Helper setup do init Redis.new(OPTIONS) end test "AUTH" do replies = { :auth => lambda { |password| $auth = password; "+OK" }, :get => lambda { |key| $auth == "secret" ? "$3\r\nbar" : "$-1" }, } redis_mock(replies) do redis = Redis.new(OPTIONS.merge(:port => 6380, :password => "secret")) assert "bar" == redis.get("foo") end end test "PING" do |r| assert "PONG" == r.ping end test "SELECT" do |r| r.set "foo", "bar" r.select 14 assert nil == r.get("foo") r.client.disconnect assert nil == r.get("foo") end test "QUIT" do |r| r.quit assert !r.client.connected? end test "SHUTDOWN" do redis_mock(:shutdown => lambda { "+SHUTDOWN" }) do redis = Redis.new(OPTIONS.merge(:port => 6380)) assert "SHUTDOWN" == redis.shutdown end end test "SLAVEOF" do redis_mock(:slaveof => lambda { |host, port| "+SLAVEOF #{host} #{port}" }) do redis = Redis.new(OPTIONS.merge(:port => 6380)) assert "SLAVEOF localhost 6381" == redis.slaveof("localhost", 6381) end end test "BGREWRITEAOF" do redis_mock(:bgrewriteaof => lambda { "+BGREWRITEAOF" }) do redis = Redis.new(OPTIONS.merge(:port => 6380)) assert "BGREWRITEAOF" == redis.bgrewriteaof end end test "CONFIG GET" do |r| assert "300" == r.config(:get, "*")["timeout"] assert r.config(:get, "timeout") == { "timeout" => "300" } end test "CONFIG SET" do |r| begin assert "OK" == r.config(:set, "timeout", 200) assert "200" == r.config(:get, "*")["timeout"] assert "OK" == r.config(:set, "timeout", 100) assert "100" == r.config(:get, "*")["timeout"] ensure r.config :set, "timeout", 300 end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
modesty-0.1.0 | vendor/redis-rb/test/connection_handling_test.rb |
redis-2.2.0 | test/connection_handling_test.rb |