Skip to content

Commit

Permalink
Skip individual tests upon Dalli::RingError
Browse files Browse the repository at this point in the history
Unlike the outer `rescue`, this one is much more precise about what we
want to handle: a connection failure (`Dalli::RingError`) is not
relevant to what we're testing here. But other Dalli errors may well be
indicating an actual problem.
  • Loading branch information
matthewd committed Jun 6, 2014
1 parent 128ad1b commit 96882f8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions actionpack/test/dispatch/session/mem_cache_store_test.rb
Expand Up @@ -48,6 +48,8 @@ def test_setting_and_getting_session_value
assert_response :success assert_response :success
assert_equal 'foo: "bar"', response.body assert_equal 'foo: "bar"', response.body
end end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end end


def test_getting_nil_session_value def test_getting_nil_session_value
Expand All @@ -56,6 +58,8 @@ def test_getting_nil_session_value
assert_response :success assert_response :success
assert_equal 'foo: nil', response.body assert_equal 'foo: nil', response.body
end end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end end


def test_getting_session_value_after_session_reset def test_getting_session_value_after_session_reset
Expand All @@ -75,6 +79,8 @@ def test_getting_session_value_after_session_reset
assert_response :success assert_response :success
assert_equal 'foo: nil', response.body, "data for this session should have been obliterated from memcached" assert_equal 'foo: nil', response.body, "data for this session should have been obliterated from memcached"
end end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end end


def test_getting_from_nonexistent_session def test_getting_from_nonexistent_session
Expand All @@ -84,6 +90,8 @@ def test_getting_from_nonexistent_session
assert_equal 'foo: nil', response.body assert_equal 'foo: nil', response.body
assert_nil cookies['_session_id'], "should only create session on write, not read" assert_nil cookies['_session_id'], "should only create session on write, not read"
end end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end end


def test_setting_session_value_after_session_reset def test_setting_session_value_after_session_reset
Expand All @@ -105,6 +113,8 @@ def test_setting_session_value_after_session_reset
assert_response :success assert_response :success
assert_not_equal session_id, response.body assert_not_equal session_id, response.body
end end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end end


def test_getting_session_id def test_getting_session_id
Expand All @@ -118,6 +128,8 @@ def test_getting_session_id
assert_response :success assert_response :success
assert_equal session_id, response.body, "should be able to read session id without accessing the session hash" assert_equal session_id, response.body, "should be able to read session id without accessing the session hash"
end end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end end


def test_deserializes_unloaded_class def test_deserializes_unloaded_class
Expand All @@ -132,6 +144,8 @@ def test_deserializes_unloaded_class
assert_response :success assert_response :success
end end
end end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end end


def test_doesnt_write_session_cookie_if_session_id_is_already_exists def test_doesnt_write_session_cookie_if_session_id_is_already_exists
Expand All @@ -144,6 +158,8 @@ def test_doesnt_write_session_cookie_if_session_id_is_already_exists
assert_response :success assert_response :success
assert_equal nil, headers['Set-Cookie'], "should not resend the cookie again if session_id cookie is already exists" assert_equal nil, headers['Set-Cookie'], "should not resend the cookie again if session_id cookie is already exists"
end end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end end


def test_prevents_session_fixation def test_prevents_session_fixation
Expand All @@ -159,6 +175,8 @@ def test_prevents_session_fixation
assert_response :success assert_response :success
assert_not_equal session_id, cookies['_session_id'] assert_not_equal session_id, cookies['_session_id']
end end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace
end end
rescue LoadError, RuntimeError, Dalli::DalliError rescue LoadError, RuntimeError, Dalli::DalliError
$stderr.puts "Skipping MemCacheStoreTest tests. Start memcached and try again." $stderr.puts "Skipping MemCacheStoreTest tests. Start memcached and try again."
Expand Down

0 comments on commit 96882f8

Please sign in to comment.