hoodoo 1.16.0 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/hoodoo/services/services/session.rb +0 -1
- data/lib/hoodoo/transient_store.rb +5 -0
- data/lib/hoodoo/transient_store/transient_store/memcached.rb +8 -1
- data/lib/hoodoo/transient_store/transient_store/redis.rb +5 -0
- data/lib/hoodoo/version.rb +1 -1
- data/spec/services/services/session_spec.rb +0 -1
- data/spec/spec_helper.rb +21 -1
- data/spec/transient_store/transient_store/memcached_redis_mirror_spec.rb +0 -3
- data/spec/transient_store/transient_store/memcached_spec.rb +0 -2
- data/spec/transient_store/transient_store/mocks/dalli_client_spec.rb +37 -0
- data/spec/transient_store/transient_store/mocks/redis_spec.rb +37 -0
- data/spec/transient_store/transient_store/redis_spec.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c9903a7189fc118fdbc3deae1277da2602c64b9
|
4
|
+
data.tar.gz: b5b04be6a1c82e1958cf70863270a282256a51bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 333ed5e667ade4ab94ee3f16dfb37e84351ab8678a09d5ffc325021b07e56e6bd3c95f820cec9ede6586c542de8abcad1746418f99e17c1ded693afb873efc51
|
7
|
+
data.tar.gz: 912f44dce0110b695c2815f969aa3a6a00e5ad88caf48e65578cb6097ef45f91446b59748523a8d8a65770b0d60f203f462ad5b479382feee4058e5e7a96d2a7
|
@@ -17,3 +17,8 @@ require 'hoodoo/transient_store/transient_store/base'
|
|
17
17
|
require 'hoodoo/transient_store/transient_store/memcached'
|
18
18
|
require 'hoodoo/transient_store/transient_store/redis'
|
19
19
|
require 'hoodoo/transient_store/transient_store/memcached_redis_mirror'
|
20
|
+
|
21
|
+
# Mock plugin back-ends for test or other stubbing purposes.
|
22
|
+
|
23
|
+
require 'hoodoo/transient_store/mocks/dalli_client'
|
24
|
+
require 'hoodoo/transient_store/mocks/redis'
|
@@ -78,13 +78,20 @@ module Hoodoo
|
|
78
78
|
# Connect to Memcached if possible and return the connected Dalli client
|
79
79
|
# instance, else raise an exception.
|
80
80
|
#
|
81
|
-
# +host+::
|
81
|
+
# +host+:: Connection URI, e.g. <tt>localhost:11211</tt>.
|
82
|
+
# +namespace+:: Key namespace (prefix), as a String or Symbol; e.g.
|
83
|
+
# <tt>"nz_co_loyalty_hoodoo_transient_store_"</tt>.
|
82
84
|
#
|
83
85
|
def connect_to_memcached( host, namespace )
|
84
86
|
exception = nil
|
85
87
|
stats = nil
|
86
88
|
client = nil
|
87
89
|
|
90
|
+
if Hoodoo::Services::Middleware.environment.test? &&
|
91
|
+
( host.nil? || host.empty? )
|
92
|
+
return Hoodoo::TransientStore::Mocks::DalliClient.new
|
93
|
+
end
|
94
|
+
|
88
95
|
begin
|
89
96
|
client = ::Dalli::Client.new(
|
90
97
|
host,
|
data/lib/hoodoo/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -197,7 +197,27 @@ end
|
|
197
197
|
# &block:: Block of code to call while +STDOUT+ is disabled.
|
198
198
|
#
|
199
199
|
def spec_helper_silence_stdout( &block )
|
200
|
-
|
200
|
+
spec_helper_silence_stream( $stdout, &block )
|
201
|
+
end
|
202
|
+
|
203
|
+
# Back-end to #spec_helper_silence_stdout; can silence arbitrary streams.
|
204
|
+
#
|
205
|
+
# +stream+:: The output stream to silence, e.g. <tt>$stdout</tt>
|
206
|
+
# &block:: Block of code to call while output stream is disabled.
|
207
|
+
#
|
208
|
+
def spec_helper_silence_stream( stream, &block )
|
209
|
+
begin
|
210
|
+
old_stream = stream.dup
|
211
|
+
stream.reopen( File::NULL )
|
212
|
+
stream.sync = true
|
213
|
+
|
214
|
+
yield
|
215
|
+
|
216
|
+
ensure
|
217
|
+
stream.reopen( old_stream )
|
218
|
+
old_stream.close
|
219
|
+
|
220
|
+
end
|
201
221
|
end
|
202
222
|
|
203
223
|
# Start up a service application under WEBrick via Rack on localhost, using
|
@@ -1,8 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
require 'hoodoo/transient_store/mocks/dalli_client'
|
4
|
-
require 'hoodoo/transient_store/mocks/redis'
|
5
|
-
|
6
3
|
# These tests make sure that the mirror class calls down to the Memcached and
|
7
4
|
# Redis abstractions, but assumes those abstractions are thoroughly tested by
|
8
5
|
# their own unit tests. So it makes sure it gets expected call and result
|
@@ -41,4 +41,41 @@ describe Hoodoo::TransientStore::Mocks::DalliClient do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
context 'approximate old behaviour by' do
|
45
|
+
it 'using the mock client in test mode if there is an empty host' do
|
46
|
+
expect_any_instance_of( Hoodoo::TransientStore::Mocks::DalliClient ).to receive( :initialize ).once.and_call_original()
|
47
|
+
|
48
|
+
Hoodoo::TransientStore::Memcached.new(
|
49
|
+
storage_host_uri: '',
|
50
|
+
namespace: 'test_namespace_'
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'using the mock client in test mode if there is a "nil" host' do
|
55
|
+
expect_any_instance_of( Hoodoo::TransientStore::Mocks::DalliClient ).to receive( :initialize ).once.and_call_original()
|
56
|
+
|
57
|
+
Hoodoo::TransientStore::Memcached.new(
|
58
|
+
storage_host_uri: nil,
|
59
|
+
namespace: 'test_namespace_'
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'using a real client in test mode if there is a defined host' do
|
64
|
+
expect_any_instance_of( ::Dalli::Client ).to receive( :initialize ).once.and_call_original()
|
65
|
+
|
66
|
+
# Silence 'Errno::ECONNREFUSED' warnings if Memcached is not actually
|
67
|
+
# running at the given URI. That's fine; it's the initializer test
|
68
|
+
# above which is important.
|
69
|
+
#
|
70
|
+
spec_helper_silence_stream( $stdout ) do
|
71
|
+
spec_helper_silence_stream( $stderr ) do
|
72
|
+
Hoodoo::TransientStore::Memcached.new(
|
73
|
+
storage_host_uri: 'localhost:11211',
|
74
|
+
namespace: 'test_namespace_'
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
44
81
|
end
|
@@ -25,4 +25,41 @@ describe Hoodoo::TransientStore::Mocks::Redis do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
context 'mimic approcimated old behaviour of its Memcached counterpart by' do
|
29
|
+
it 'using the mock client in test mode if there is an empty host' do
|
30
|
+
expect_any_instance_of( Hoodoo::TransientStore::Mocks::Redis ).to receive( :initialize ).once.and_call_original()
|
31
|
+
|
32
|
+
Hoodoo::TransientStore::Redis.new(
|
33
|
+
storage_host_uri: '',
|
34
|
+
namespace: 'test_namespace_'
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'using the mock client in test mode if there is a "nil" host' do
|
39
|
+
expect_any_instance_of( Hoodoo::TransientStore::Mocks::Redis ).to receive( :initialize ).once.and_call_original()
|
40
|
+
|
41
|
+
Hoodoo::TransientStore::Redis.new(
|
42
|
+
storage_host_uri: nil,
|
43
|
+
namespace: 'test_namespace_'
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'using a real client in test mode if there is a defined host' do
|
48
|
+
expect_any_instance_of( ::Redis ).to receive( :initialize ).once.and_call_original()
|
49
|
+
|
50
|
+
# Silence 'Errno::ECONNREFUSED' warnings if Memcached is not actually
|
51
|
+
# running at the given URI. That's fine; it's the initializer test
|
52
|
+
# above which is important.
|
53
|
+
#
|
54
|
+
spec_helper_silence_stream( $stdout ) do
|
55
|
+
spec_helper_silence_stream( $stderr ) do
|
56
|
+
Hoodoo::TransientStore::Redis.new(
|
57
|
+
storage_host_uri: 'redis://localhost:6379',
|
58
|
+
namespace: 'test_namespace_'
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
28
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoodoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loyalty New Zealand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dalli
|