Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip padrino cache test if can not connect to cache server #1088

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 18 additions & 10 deletions padrino-cache/test/test_stores.rb
Expand Up @@ -40,13 +40,17 @@ def bar; "bar"; end
HERE_DOC

begin
require 'memcache'
require 'Memcached'
# we're just going to assume memcached is running on the default port
Padrino::Cache::Store::Memcache.new(::MemCache.new('127.0.0.1:11211', :exception_retry_limit => 1)).set('ping','alive')

Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1)).set('ping','alive')
rescue LoadError
warn "Skipping memcache with memcached library tests"
rescue Memcached::SystemError
warn "Skipping memcache with memcached server tests"
else
describe "MemcacheStore" do
def setup
Padrino.cache = Padrino::Cache::Store::Memcache.new(::MemCache.new('127.0.0.1:11211', :exception_retry_limit => 1))
Padrino.cache = Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1))
Padrino.cache.flush
end

Expand All @@ -56,8 +60,6 @@ def teardown

eval COMMON_TESTS
end
rescue LoadError
warn "Skipping memcache with memcached library tests"
end

begin
Expand Down Expand Up @@ -86,6 +88,11 @@ def teardown
begin
require 'redis'
Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0).set('ping','alive'))
rescue LoadError
warn "Skipping redis with redis library tests"
rescue Redis::CannotConnectError
warn "Skipping redis with redis server tests"
else
describe "RedisStore" do
def setup
Padrino.cache = Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0))
Expand All @@ -106,13 +113,16 @@ def teardown

eval COMMON_TESTS
end
rescue LoadError
warn "Skipping redis tests"
end

begin
require 'mongo'
Padrino::Cache::Store::Mongo.new(::Mongo::Connection.new('127.0.0.1', 27017).db('padrino-cache_test'))
rescue LoadError
warn "Skipping Mongo tests with Mongo library tests"
rescue Mongo::ConnectionFailure
warn "Skipping Mongo Mongo with Mongo server tests"
else
describe "MongoStore" do
def setup
Padrino.cache = Padrino::Cache::Store::Mongo.new(::Mongo::Connection.new('127.0.0.1', 27017).db('padrino-cache_test'), {:size => 10, :collection => 'cache'})
Expand All @@ -126,8 +136,6 @@ def teardown

eval COMMON_TESTS
end
rescue LoadError, Mongo::ConnectionFailure
warn "Skipping Mongo tests"
end

describe "FileStore" do
Expand Down