Sha256: 34494465aa7f09e3baf29424a66f8971f25d4883b4721c435c5c882b33a7eac5
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 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:19123' dc.get 'foo' end end context 'with a fake server' do should 'handle connection reset' do memcached_mock(lambda {|sock| sock.close }) do assert_error Dalli::NetworkError, /ECONNRESET/ 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, /EOFError/ 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, /Timeout::Error/ 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, /Timeout::Error/ 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.9.1 | test/test_network.rb |