-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Redis Connection to be Injected
See issue #188 for details. Prior to this change, pooled redis connections were hard to share across. Now you can inject your own redis connection into the intiailizer via the `redis_conn` parameter.
- Loading branch information
Anthony Ross
committed
Nov 4, 2019
1 parent
0d5564a
commit 372025d
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
require_relative './backend_common_tests' | ||
|
||
class BackendRedisInjectedTest < Minitest::Test | ||
include BackendCommonTests | ||
|
||
def setup | ||
begin | ||
require 'redis' | ||
rescue LoadError | ||
raise NoRedisError | ||
end | ||
|
||
redis = Redis.new | ||
@backend = ClassifierReborn::BayesRedisBackend.new(redis_conn: redis) | ||
redis.config(:set, 'save', '') | ||
rescue Redis::CannotConnectError => e | ||
skip(e) | ||
end | ||
|
||
def teardown | ||
@backend.reset if defined? @backend | ||
end | ||
end |