couchbase-jruby-client 0.1.2 → 0.1.3
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/couchbase-jruby-client.gemspec +1 -1
- data/lib/couchbase.rb +21 -15
- data/lib/couchbase/bucket.rb +39 -41
- data/lib/couchbase/operations/store.rb +1 -1
- data/lib/couchbase/version.rb +1 -1
- data/test/setup.rb +8 -145
- data/test/test_arithmetic.rb +53 -76
- data/test/test_async.rb +74 -102
- data/test/test_bucket.rb +71 -63
- data/test/test_cas.rb +9 -23
- data/test/test_couchbase.rb +5 -4
- data/test/test_delete.rb +41 -43
- data/test/test_design_docs.rb +8 -18
- data/test/test_errors.rb +9 -18
- data/test/test_format.rb +21 -31
- data/test/test_get.rb +107 -150
- data/test/test_stats.rb +9 -24
- data/test/test_store.rb +53 -62
- data/test/test_timer.rb +3 -12
- data/test/test_touch.rb +26 -33
- data/test/test_unlock.rb +45 -78
- data/test/test_utils.rb +2 -11
- data/test/test_version.rb +4 -14
- data/test/test_view.rb +4 -11
- metadata +5 -5
data/test/test_async.rb
CHANGED
@@ -19,14 +19,6 @@ require File.join(File.dirname(__FILE__), 'setup')
|
|
19
19
|
|
20
20
|
class TestAsync < MiniTest::Test
|
21
21
|
|
22
|
-
def setup
|
23
|
-
@mock = start_mock
|
24
|
-
end
|
25
|
-
|
26
|
-
def teardown
|
27
|
-
stop_mock(@mock)
|
28
|
-
end
|
29
|
-
|
30
22
|
def test_result_object_provides_enough_info
|
31
23
|
obj = Couchbase::Result.new
|
32
24
|
assert obj.respond_to?(:success?)
|
@@ -38,33 +30,29 @@ class TestAsync < MiniTest::Test
|
|
38
30
|
end
|
39
31
|
|
40
32
|
def test_it_requires_block_for_running_loop
|
41
|
-
|
42
|
-
refute connection.async?
|
33
|
+
refute cb.async?
|
43
34
|
assert_raises(LocalJumpError) do
|
44
|
-
|
35
|
+
cb.run
|
45
36
|
end
|
46
|
-
|
37
|
+
cb.run do |conn|
|
47
38
|
assert conn.async?
|
48
39
|
end
|
49
40
|
end
|
50
41
|
|
51
42
|
def test_it_resets_async_flag_when_raising_exception_from_callback
|
52
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
53
|
-
|
54
43
|
assert_raises(RuntimeError) do
|
55
|
-
|
44
|
+
cb.run do |conn|
|
56
45
|
conn.set(uniq_id, "foo") { raise }
|
57
46
|
end
|
58
47
|
end
|
59
|
-
refute
|
48
|
+
refute cb.async?
|
60
49
|
end
|
61
50
|
|
62
51
|
def test_nested_async_get_set
|
63
|
-
|
64
|
-
|
65
|
-
connection.set(uniq_id(:hit), 0)
|
52
|
+
cb.set(uniq_id, {"bar" => 1})
|
53
|
+
cb.set(uniq_id(:hit), 0)
|
66
54
|
|
67
|
-
|
55
|
+
cb.run do |conn|
|
68
56
|
conn.get(uniq_id) do
|
69
57
|
conn.get(uniq_id(:hit)) do |res|
|
70
58
|
conn.set(uniq_id(:hit), res.value + 1)
|
@@ -72,15 +60,14 @@ class TestAsync < MiniTest::Test
|
|
72
60
|
end
|
73
61
|
end
|
74
62
|
|
75
|
-
val =
|
63
|
+
val = cb.get(uniq_id(:hit))
|
76
64
|
assert_equal 1, val
|
77
65
|
end
|
78
66
|
|
79
67
|
def test_nested_async_set_get
|
80
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
81
68
|
val = nil
|
82
69
|
|
83
|
-
|
70
|
+
cb.run do |conn|
|
84
71
|
conn.set(uniq_id, "foo") do
|
85
72
|
conn.get(uniq_id) do |res|
|
86
73
|
val = res.value
|
@@ -92,12 +79,11 @@ class TestAsync < MiniTest::Test
|
|
92
79
|
end
|
93
80
|
|
94
81
|
def test_nested_async_touch_get
|
95
|
-
|
96
|
-
connection.set(uniq_id, "foo")
|
82
|
+
cb.set(uniq_id, "foo")
|
97
83
|
success = false
|
98
84
|
val = nil
|
99
85
|
|
100
|
-
|
86
|
+
cb.run do |conn|
|
101
87
|
conn.touch(uniq_id, :ttl => 1) do |res1|
|
102
88
|
success = res1.success?
|
103
89
|
conn.get(uniq_id) do |res2|
|
@@ -110,17 +96,16 @@ class TestAsync < MiniTest::Test
|
|
110
96
|
assert_equal "foo", val
|
111
97
|
sleep(2)
|
112
98
|
assert_raises(Couchbase::Error::NotFound) do
|
113
|
-
|
99
|
+
cb.get(uniq_id)
|
114
100
|
end
|
115
101
|
end
|
116
102
|
|
117
103
|
def test_nested_async_delete_get
|
118
|
-
|
119
|
-
cas = connection.set(uniq_id, "foo")
|
104
|
+
cas = cb.set(uniq_id, "foo")
|
120
105
|
success = false
|
121
106
|
val = :unknown
|
122
107
|
|
123
|
-
|
108
|
+
cb.run do |conn|
|
124
109
|
conn.delete(uniq_id, :cas => cas) do |res1|
|
125
110
|
success = res1.success?
|
126
111
|
conn.get(uniq_id, :quiet => true) do |res2|
|
@@ -135,10 +120,9 @@ class TestAsync < MiniTest::Test
|
|
135
120
|
|
136
121
|
def test_nested_async_stats_set
|
137
122
|
skip
|
138
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
139
123
|
stats = {}
|
140
124
|
|
141
|
-
|
125
|
+
cb.run do |conn|
|
142
126
|
conn.stats do |res1|
|
143
127
|
id = uniq_id(res1.node, res1.key)
|
144
128
|
stats[id] = false
|
@@ -155,41 +139,35 @@ class TestAsync < MiniTest::Test
|
|
155
139
|
|
156
140
|
def test_nested_async_flush_set
|
157
141
|
skip
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
res[id] =
|
168
|
-
conn.set(id, true) do |res2|
|
169
|
-
res[id] = res2.cas
|
170
|
-
end
|
142
|
+
cas = cb.set(uniq_id, "foo")
|
143
|
+
res = {}
|
144
|
+
|
145
|
+
cb.run do |conn|
|
146
|
+
conn.flush do |res1|
|
147
|
+
assert res1.success?, "Expected: successful status code.\nActual: #{res1.error.inspect}"
|
148
|
+
id = uniq_id(res1.node)
|
149
|
+
res[id] = false
|
150
|
+
conn.set(id, true) do |res2|
|
151
|
+
res[id] = res2.cas
|
171
152
|
end
|
172
153
|
end
|
154
|
+
end
|
173
155
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
end
|
181
|
-
else
|
182
|
-
skip("REST FLUSH isn't implemented in CouchbaseMock.jar yet")
|
156
|
+
assert_raises(Couchbase::Error::NotFound) do
|
157
|
+
cb.get(uniq_id)
|
158
|
+
end
|
159
|
+
res.keys.each do |key|
|
160
|
+
assert res[key].is_a?(Numeric)
|
161
|
+
assert cb.get(key)
|
183
162
|
end
|
184
163
|
end
|
185
164
|
|
186
165
|
def test_nested_async_incr_get
|
187
166
|
skip
|
188
|
-
|
189
|
-
cas = connection.set(uniq_id, 1)
|
167
|
+
cas = cb.set(uniq_id, 1)
|
190
168
|
val = nil
|
191
169
|
|
192
|
-
|
170
|
+
cb.run do |conn|
|
193
171
|
conn.incr(uniq_id) do
|
194
172
|
conn.get(uniq_id) do |res|
|
195
173
|
val = res.value
|
@@ -201,28 +179,26 @@ class TestAsync < MiniTest::Test
|
|
201
179
|
end
|
202
180
|
|
203
181
|
def test_it_doesnt_accept_callbacks_in_synchronous_mode
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
assert_raises(ArgumentError) {
|
208
|
-
assert_raises(ArgumentError) {
|
209
|
-
assert_raises(ArgumentError) {
|
210
|
-
assert_raises(ArgumentError) {
|
211
|
-
assert_raises(ArgumentError) {
|
212
|
-
assert_raises(ArgumentError) {
|
213
|
-
assert_raises(ArgumentError) {
|
214
|
-
assert_raises(ArgumentError) {
|
215
|
-
assert_raises(ArgumentError) {
|
216
|
-
assert_raises(ArgumentError) {
|
217
|
-
assert_raises(ArgumentError) {
|
218
|
-
assert_raises(ArgumentError) { connection.stats {} }
|
182
|
+
refute cb.async?
|
183
|
+
|
184
|
+
assert_raises(ArgumentError) { cb.add(uniq_id, "foo") {} }
|
185
|
+
assert_raises(ArgumentError) { cb.set(uniq_id, "foo") {} }
|
186
|
+
assert_raises(ArgumentError) { cb.replace(uniq_id, "foo") {} }
|
187
|
+
assert_raises(ArgumentError) { cb.get(uniq_id) {} }
|
188
|
+
assert_raises(ArgumentError) { cb.touch(uniq_id) {} }
|
189
|
+
assert_raises(ArgumentError) { cb.incr(uniq_id) {} }
|
190
|
+
assert_raises(ArgumentError) { cb.decr(uniq_id) {} }
|
191
|
+
assert_raises(ArgumentError) { cb.delete(uniq_id) {} }
|
192
|
+
assert_raises(ArgumentError) { cb.append(uniq_id, "bar") {} }
|
193
|
+
assert_raises(ArgumentError) { cb.prepend(uniq_id, "bar") {} }
|
194
|
+
assert_raises(ArgumentError) { cb.flush {} }
|
195
|
+
assert_raises(ArgumentError) { cb.stats {} }
|
219
196
|
end
|
220
197
|
|
221
198
|
def test_it_disallow_nested_run
|
222
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
223
199
|
assert_raises(Couchbase::Error::Invalid) do
|
224
|
-
|
225
|
-
|
200
|
+
cb.run do
|
201
|
+
cb.run do
|
226
202
|
end
|
227
203
|
end
|
228
204
|
end
|
@@ -230,12 +206,11 @@ class TestAsync < MiniTest::Test
|
|
230
206
|
|
231
207
|
def test_it_extends_timeout_in_async_mode_if_needed
|
232
208
|
skip
|
233
|
-
|
234
|
-
connection.set(uniq_id, "foo")
|
209
|
+
cb.set(uniq_id, "foo")
|
235
210
|
|
236
|
-
|
237
|
-
|
238
|
-
|
211
|
+
cb.timeout = 100_000 # 100_000 us
|
212
|
+
cb.run do
|
213
|
+
cb.get(uniq_id) do |ret|
|
239
214
|
assert ret.success?
|
240
215
|
assert_equal "foo", ret.value
|
241
216
|
end
|
@@ -245,11 +220,9 @@ class TestAsync < MiniTest::Test
|
|
245
220
|
|
246
221
|
def test_send_threshold
|
247
222
|
skip
|
248
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
249
|
-
|
250
223
|
sent = false
|
251
|
-
|
252
|
-
|
224
|
+
cb.run(:send_threshold => 100) do # 100 bytes
|
225
|
+
cb.set(uniq_id, "foo" * 100) {|r| sent = true}
|
253
226
|
assert sent
|
254
227
|
end
|
255
228
|
end
|
@@ -257,27 +230,26 @@ class TestAsync < MiniTest::Test
|
|
257
230
|
def test_asynchronous_connection
|
258
231
|
skip
|
259
232
|
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :async => true)
|
260
|
-
refute
|
261
|
-
|
233
|
+
refute cb.connected?, "new asynchronous connection must be disconnected"
|
234
|
+
cb.on_connect do |res|
|
262
235
|
assert res.success?, "on_connect called with error #{res.error.inspect}"
|
263
236
|
assert_same connection, res.bucket
|
264
237
|
end
|
265
|
-
|
266
|
-
assert
|
238
|
+
cb.run {}
|
239
|
+
assert cb.connected?, "it should be connected after first run"
|
267
240
|
end
|
268
241
|
|
269
242
|
def test_it_calls_callback_immediately_if_connected_sync
|
270
243
|
skip
|
271
|
-
|
272
|
-
assert connection.connected?, "connection wasn't established in sync mode"
|
244
|
+
assert cb.connected?, "connection wasn't established in sync mode"
|
273
245
|
called = false
|
274
|
-
|
246
|
+
cb.on_connect do |res|
|
275
247
|
assert res.success?, "on_connect called with error #{res.error.inspect}"
|
276
248
|
called = true
|
277
249
|
end
|
278
250
|
assert called, "the callback hasn't been called on set"
|
279
251
|
called = false
|
280
|
-
|
252
|
+
cb.on_connect do |res|
|
281
253
|
assert res.success?, "on_connect called with error #{res.error.inspect}"
|
282
254
|
called = true
|
283
255
|
end
|
@@ -287,20 +259,20 @@ class TestAsync < MiniTest::Test
|
|
287
259
|
def test_it_calls_callback_immediately_if_connected_async
|
288
260
|
skip
|
289
261
|
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :async => true)
|
290
|
-
refute
|
262
|
+
refute cb.connected?, "new asynchronous connection must be disconnected"
|
291
263
|
called = false
|
292
|
-
|
293
|
-
assert
|
294
|
-
|
295
|
-
|
264
|
+
cb.run {}
|
265
|
+
assert cb.connected?, "the connection must be established"
|
266
|
+
cb.run do
|
267
|
+
cb.on_connect do |res|
|
296
268
|
assert res.success?, "on_connect called with error #{res.error.inspect}"
|
297
269
|
called = true
|
298
270
|
end
|
299
271
|
end
|
300
272
|
assert called, "the callback hasn't been called on set"
|
301
273
|
called = false
|
302
|
-
|
303
|
-
|
274
|
+
cb.run do
|
275
|
+
cb.on_connect do |res|
|
304
276
|
assert res.success?, "on_connect called with error #{res.error.inspect}"
|
305
277
|
called = true
|
306
278
|
end
|
@@ -311,12 +283,12 @@ class TestAsync < MiniTest::Test
|
|
311
283
|
def test_it_returns_error_if_user_start_work_on_disconnected_instance_outside_on_connect_callback
|
312
284
|
skip
|
313
285
|
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :async => true)
|
314
|
-
refute
|
286
|
+
refute cb.connected?, "new asynchronous connection must be disconnected"
|
315
287
|
error = nil
|
316
|
-
|
288
|
+
cb.on_error do |ex|
|
317
289
|
error = ex
|
318
290
|
end
|
319
|
-
|
291
|
+
cb.run do |c|
|
320
292
|
c.set("foo", "bar")
|
321
293
|
end
|
322
294
|
assert_instance_of(Couchbase::Error::Connect, error)
|
data/test/test_bucket.rb
CHANGED
@@ -20,31 +20,32 @@ require File.join(File.dirname(__FILE__), 'setup')
|
|
20
20
|
class TestBucket < MiniTest::Test
|
21
21
|
|
22
22
|
def test_it_substitute_default_parts_to_url
|
23
|
-
|
24
|
-
with_mock(:host => 'localhost') do |mock| # pick first free port
|
23
|
+
with_configs(:host => 'localhost') do |configs| # pick first free port
|
25
24
|
connections = [
|
26
|
-
Couchbase.new("http://#{
|
27
|
-
Couchbase.new(:port =>
|
28
|
-
Couchbase.new("http://#{
|
25
|
+
Couchbase.new("http://#{configs.host}:#{configs.port}"),
|
26
|
+
Couchbase.new(:port => configs.port),
|
27
|
+
Couchbase.new("http://#{configs.host}:8091", :port => configs.port)
|
29
28
|
]
|
30
29
|
connections.each do |connection|
|
31
|
-
assert_equal
|
32
|
-
assert_equal "#{
|
33
|
-
assert_equal "http://#{
|
30
|
+
assert_equal configs.port, connection.port
|
31
|
+
assert_equal "#{configs.host}:#{configs.port}", connection.authority
|
32
|
+
assert_equal "http://#{configs.host}:#{configs.port}/pools/default/buckets/default/", connection.url
|
34
33
|
end
|
34
|
+
connections.each(&:disconnect)
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
with_configs(:host => '127.0.0.1') do |configs|
|
38
38
|
connections = [
|
39
|
-
Couchbase.new("http://#{
|
40
|
-
Couchbase.new(:hostname =>
|
41
|
-
Couchbase.new('http://example.com:8091', :hostname =>
|
39
|
+
Couchbase.new("http://#{configs.host}:#{configs.port}"),
|
40
|
+
Couchbase.new(:hostname => configs.host, :port => configs.port),
|
41
|
+
Couchbase.new('http://example.com:8091', :hostname => configs.host, :port => configs.port)
|
42
42
|
]
|
43
43
|
connections.each do |connection|
|
44
|
-
assert_equal
|
45
|
-
assert_equal "#{
|
46
|
-
assert_equal "http://#{
|
44
|
+
assert_equal configs.host, connection.hostname
|
45
|
+
assert_equal "#{configs.host}:#{configs.port}", connection.authority
|
46
|
+
assert_equal "http://#{configs.host}:#{configs.port}/pools/default/buckets/default/", connection.url
|
47
47
|
end
|
48
|
+
connections.each(&:disconnect)
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
@@ -70,32 +71,36 @@ class TestBucket < MiniTest::Test
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def test_it_able_to_connect_to_protected_buckets
|
73
|
-
|
74
|
-
|
75
|
-
|
74
|
+
skip
|
75
|
+
with_configs(:buckets_spec => 'protected:secret') do |configs|
|
76
|
+
connection = Couchbase.new(:hostname => configs.host,
|
77
|
+
:port => configs.port,
|
76
78
|
:bucket => 'protected',
|
77
79
|
:username => 'protected',
|
78
80
|
:password => 'secret')
|
79
81
|
assert_equal "protected", connection.bucket
|
80
82
|
assert_equal "protected", connection.username
|
81
83
|
assert_equal "secret", connection.password
|
84
|
+
connection.disconnect
|
82
85
|
end
|
83
86
|
end
|
84
87
|
|
85
88
|
def test_it_allows_to_specify_credentials_in_url
|
86
|
-
|
87
|
-
|
89
|
+
skip
|
90
|
+
with_configs(:buckets_spec => 'protected:secret') do |configs|
|
91
|
+
connection = Couchbase.new("http://protected:secret@#{configs.host}:#{configs.port}/pools/default/buckets/protected/")
|
88
92
|
assert_equal "protected", connection.bucket
|
89
93
|
assert_equal "protected", connection.username
|
90
94
|
assert_equal "secret", connection.password
|
95
|
+
connection.disconnect
|
91
96
|
end
|
92
97
|
end
|
93
98
|
|
94
99
|
def test_it_raises_error_with_wrong_credentials
|
95
|
-
|
100
|
+
with_configs do |configs|
|
96
101
|
assert_raises Couchbase::Error::Auth do
|
97
|
-
Couchbase.new(:hostname =>
|
98
|
-
:port =>
|
102
|
+
Couchbase.new(:hostname => configs.host,
|
103
|
+
:port => configs.port,
|
99
104
|
:bucket => 'default',
|
100
105
|
:username => 'wrong.username',
|
101
106
|
:password => 'wrong_password')
|
@@ -104,17 +109,18 @@ class TestBucket < MiniTest::Test
|
|
104
109
|
end
|
105
110
|
|
106
111
|
def test_it_unable_to_connect_to_protected_buckets_with_wrong_credentials
|
107
|
-
|
112
|
+
skip
|
113
|
+
with_configs(:buckets_spec => 'protected:secret') do |configs|
|
108
114
|
assert_raises Couchbase::Error::Auth do
|
109
|
-
Couchbase.new(:hostname =>
|
110
|
-
:port =>
|
115
|
+
Couchbase.new(:hostname => configs.host,
|
116
|
+
:port => configs.port,
|
111
117
|
:bucket => 'protected',
|
112
118
|
:username => 'wrong',
|
113
119
|
:password => 'secret')
|
114
120
|
end
|
115
121
|
assert_raises Couchbase::Error::Auth do
|
116
|
-
Couchbase.new(:hostname =>
|
117
|
-
:port =>
|
122
|
+
Couchbase.new(:hostname => configs.host,
|
123
|
+
:port => configs.port,
|
118
124
|
:bucket => 'protected',
|
119
125
|
:username => 'protected',
|
120
126
|
:password => 'wrong')
|
@@ -123,14 +129,15 @@ class TestBucket < MiniTest::Test
|
|
123
129
|
end
|
124
130
|
|
125
131
|
def test_it_allows_change_quiet_flag
|
126
|
-
|
127
|
-
connection = Couchbase.new(:hostname =>
|
128
|
-
:port =>
|
132
|
+
with_configs do |configs|
|
133
|
+
connection = Couchbase.new(:hostname => configs.host,
|
134
|
+
:port => configs.port)
|
129
135
|
|
130
136
|
refute connection.quiet?
|
131
137
|
|
132
|
-
connection
|
133
|
-
|
138
|
+
connection.disconnect
|
139
|
+
connection = Couchbase.new(:hostname => configs.host,
|
140
|
+
:port => configs.port,
|
134
141
|
:quiet => true)
|
135
142
|
assert connection.quiet?
|
136
143
|
|
@@ -139,30 +146,32 @@ class TestBucket < MiniTest::Test
|
|
139
146
|
|
140
147
|
connection.quiet = :foo
|
141
148
|
assert_equal true, connection.quiet?
|
149
|
+
connection.disconnect
|
142
150
|
end
|
143
151
|
end
|
144
152
|
|
145
153
|
def test_it_is_connected
|
146
|
-
|
147
|
-
connection = Couchbase.new(:hostname =>
|
148
|
-
:port =>
|
154
|
+
with_configs do |configs|
|
155
|
+
connection = Couchbase.new(:hostname => configs.host,
|
156
|
+
:port => configs.port)
|
149
157
|
assert connection.connected?
|
158
|
+
connection.disconnect
|
150
159
|
end
|
151
160
|
end
|
152
161
|
|
153
162
|
def test_it_is_possible_to_disconnect_instance
|
154
|
-
|
155
|
-
connection = Couchbase.new(:hostname =>
|
156
|
-
:port =>
|
163
|
+
with_configs do |configs|
|
164
|
+
connection = Couchbase.new(:hostname => configs.host,
|
165
|
+
:port => configs.port)
|
157
166
|
connection.disconnect
|
158
167
|
refute connection.connected?
|
159
168
|
end
|
160
169
|
end
|
161
170
|
|
162
171
|
def test_it_raises_error_on_double_disconnect
|
163
|
-
|
164
|
-
connection = Couchbase.new(:hostname =>
|
165
|
-
:port =>
|
172
|
+
with_configs do |configs|
|
173
|
+
connection = Couchbase.new(:hostname => configs.host,
|
174
|
+
:port => configs.port)
|
166
175
|
connection.disconnect
|
167
176
|
assert_raises Couchbase::Error::Connect do
|
168
177
|
connection.disconnect
|
@@ -171,49 +180,48 @@ class TestBucket < MiniTest::Test
|
|
171
180
|
end
|
172
181
|
|
173
182
|
def test_it_allows_to_reconnect_the_instance
|
174
|
-
|
175
|
-
connection = Couchbase.new(:hostname =>
|
176
|
-
:port =>
|
183
|
+
with_configs do |configs|
|
184
|
+
connection = Couchbase.new(:hostname => configs.host,
|
185
|
+
:port => configs.port)
|
177
186
|
connection.disconnect
|
178
187
|
refute connection.connected?
|
179
188
|
connection.reconnect
|
180
189
|
assert connection.connected?
|
181
190
|
assert connection.set(uniq_id, "foo")
|
191
|
+
connection.disconnect
|
182
192
|
end
|
183
193
|
end
|
184
194
|
|
185
195
|
def test_it_allows_to_change_configuration_during_reconnect
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
:username => 'protected',
|
191
|
-
:password => 'secret')
|
196
|
+
skip
|
197
|
+
with_configs do |configs|
|
198
|
+
connection = Couchbase.new(:quiet => true)
|
199
|
+
assert connection.quiet?
|
192
200
|
connection.disconnect
|
193
|
-
assert_raises Couchbase::Error::Auth do
|
194
|
-
connection.reconnect(:password => 'incorrect')
|
195
|
-
end
|
196
|
-
refute connection.connected?
|
197
201
|
|
198
|
-
connection.reconnect(:
|
199
|
-
|
202
|
+
connection.reconnect(:quiet => false)
|
203
|
+
refute connection.quiet?
|
204
|
+
connection.disconnect
|
200
205
|
end
|
201
206
|
end
|
202
207
|
|
203
208
|
def test_it_uses_bucket_name_as_username_if_username_is_empty
|
204
|
-
|
205
|
-
|
206
|
-
|
209
|
+
skip
|
210
|
+
with_configs(:buckets_spec => 'protected:secret') do |configs|
|
211
|
+
connection = Couchbase.new(:hostname => configs.host,
|
212
|
+
:port => configs.port,
|
207
213
|
:bucket => 'protected',
|
208
214
|
:password => 'secret')
|
209
215
|
assert connection.connected?
|
216
|
+
connection.disconnect
|
210
217
|
end
|
211
218
|
end
|
212
219
|
|
213
220
|
def test_it_converts_options_keys_to_symbols
|
214
|
-
bucket = Couchbase::Bucket.new('
|
215
|
-
|
216
|
-
assert_equal
|
221
|
+
bucket = Couchbase::Bucket.new('quiet' => true, 'default_ttl' => 10)
|
222
|
+
assert bucket.quiet?
|
223
|
+
assert_equal 10, bucket.default_ttl
|
224
|
+
bucket.disconnect
|
217
225
|
end
|
218
226
|
|
219
227
|
end
|