Sha256: 32b67c9790f8ba0307b1b1119d6597efb95d5371e13e645b16528b7352cf88fc
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
require 'helper' class TestNetwork < Test::Unit::TestCase context 'assuming a bad network' do should 'handle connection refused' do assert_raise Dalli::NetworkError do dc = Dalli::Client.new 'localhost:19333' dc.get 'foo' end end context 'with a fake server' do setup do Dalli::Server.any_instance.expects(:detect_memcached_version).returns('1.4.5') end should 'handle connection reset' do memcached_mock(lambda {|sock| sock.close }) do assert_error Dalli::NetworkError, /Connection reset|end of file/ do dc = Dalli::Client.new('localhost:19123') dc.get('abc') end end end should 'handle malformed response' do memcached_mock(lambda {|sock| sock.write('123') }) do assert_error Dalli::NetworkError, /end of file/ do dc = Dalli::Client.new('localhost:19123') dc.get('abc') end end end should 'handle connect timeouts' do memcached_mock(lambda {|sock| sleep(0.6); sock.close }, :delayed_start) do assert_error Dalli::NetworkError, /IO timeout/ do dc = Dalli::Client.new('localhost:19123') dc.get('abc') end end end should 'handle read timeouts' do memcached_mock(lambda {|sock| sleep(0.6); sock.write('giraffe') }) do assert_error Dalli::NetworkError, /IO timeout/ do dc = Dalli::Client.new('localhost:19123') dc.get('abc') end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dalli-0.11.0 | test/test_network.rb |