couchbase 1.1.5-x86-mingw32 → 1.2.0.beta-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.travis.yml +12 -1
- data/HISTORY.markdown +112 -1
- data/README.markdown +149 -6
- data/couchbase.gemspec +5 -1
- data/ext/couchbase_ext/.gitignore +4 -0
- data/ext/couchbase_ext/arguments.c +973 -0
- data/ext/couchbase_ext/arithmetic.c +322 -0
- data/ext/couchbase_ext/bucket.c +1092 -0
- data/ext/couchbase_ext/couchbase_ext.c +618 -3247
- data/ext/couchbase_ext/couchbase_ext.h +519 -0
- data/ext/couchbase_ext/delete.c +167 -0
- data/ext/couchbase_ext/extconf.rb +24 -5
- data/ext/couchbase_ext/get.c +301 -0
- data/ext/couchbase_ext/gethrtime.c +124 -0
- data/ext/couchbase_ext/http.c +402 -0
- data/ext/couchbase_ext/observe.c +174 -0
- data/ext/couchbase_ext/result.c +126 -0
- data/ext/couchbase_ext/stats.c +169 -0
- data/ext/couchbase_ext/store.c +522 -0
- data/ext/couchbase_ext/timer.c +192 -0
- data/ext/couchbase_ext/touch.c +190 -0
- data/ext/couchbase_ext/unlock.c +180 -0
- data/ext/couchbase_ext/utils.c +471 -0
- data/ext/couchbase_ext/version.c +147 -0
- data/lib/action_dispatch/middleware/session/couchbase_store.rb +38 -0
- data/lib/active_support/cache/couchbase_store.rb +356 -0
- data/lib/couchbase.rb +24 -3
- data/lib/couchbase/bucket.rb +372 -9
- data/lib/couchbase/result.rb +26 -0
- data/lib/couchbase/utils.rb +59 -0
- data/lib/couchbase/version.rb +1 -1
- data/lib/couchbase/view.rb +305 -0
- data/lib/couchbase/view_row.rb +230 -0
- data/lib/ext/multi_json_fix.rb +47 -0
- data/lib/rack/session/couchbase.rb +104 -0
- data/tasks/compile.rake +5 -14
- data/test/setup.rb +6 -2
- data/test/test_arithmetic.rb +32 -2
- data/test/test_async.rb +18 -4
- data/test/test_bucket.rb +11 -1
- data/test/test_cas.rb +13 -3
- data/test/test_couchbase_rails_cache_store.rb +294 -0
- data/test/test_delete.rb +60 -3
- data/test/test_format.rb +28 -17
- data/test/test_get.rb +91 -14
- data/test/test_store.rb +31 -1
- data/test/{test_flush.rb → test_timer.rb} +11 -18
- data/test/test_touch.rb +33 -5
- data/test/test_unlock.rb +120 -0
- data/test/test_utils.rb +26 -0
- metadata +102 -12
data/test/test_delete.rb
CHANGED
@@ -31,17 +31,20 @@ class TestStore < MiniTest::Unit::TestCase
|
|
31
31
|
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
32
32
|
connection.set(uniq_id, "bar")
|
33
33
|
assert connection.delete(uniq_id)
|
34
|
-
|
34
|
+
assert_raises(Couchbase::Error::NotFound) do
|
35
|
+
connection.delete(uniq_id)
|
36
|
+
end
|
35
37
|
end
|
36
38
|
|
37
39
|
def test_delete_missing
|
38
40
|
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
39
|
-
refute connection.delete(uniq_id(:missing))
|
40
|
-
connection.quiet = false
|
41
41
|
assert_raises(Couchbase::Error::NotFound) do
|
42
42
|
connection.delete(uniq_id(:missing))
|
43
43
|
end
|
44
44
|
refute connection.delete(uniq_id(:missing), :quiet => true)
|
45
|
+
refute connection.quiet?
|
46
|
+
connection.quiet = true
|
47
|
+
refute connection.delete(uniq_id(:missing))
|
45
48
|
end
|
46
49
|
|
47
50
|
def test_delete_with_cas
|
@@ -60,4 +63,58 @@ class TestStore < MiniTest::Unit::TestCase
|
|
60
63
|
assert connection.delete(uniq_id, cas)
|
61
64
|
end
|
62
65
|
|
66
|
+
def test_delete_with_prefix
|
67
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :key_prefix => "prefix:")
|
68
|
+
connection.set(uniq_id(:foo), "bar")
|
69
|
+
assert connection.delete(uniq_id(:foo))
|
70
|
+
assert_raises(Couchbase::Error::NotFound) do
|
71
|
+
connection.get(uniq_id(:foo))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_simple_multi_delete
|
76
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
|
77
|
+
connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
|
78
|
+
res = connection.delete(uniq_id(1), uniq_id(2))
|
79
|
+
assert res.is_a?(Hash)
|
80
|
+
assert res[uniq_id(1)]
|
81
|
+
assert res[uniq_id(2)]
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_simple_multi_delete_missing
|
85
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
|
86
|
+
connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
|
87
|
+
res = connection.delete(uniq_id(1), uniq_id(:missing), :quiet => true)
|
88
|
+
assert res.is_a?(Hash)
|
89
|
+
assert res[uniq_id(1)]
|
90
|
+
refute res[uniq_id(:missing)]
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_multi_delete_with_cas_check
|
94
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
|
95
|
+
cas = connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
|
96
|
+
res = connection.delete(uniq_id(1) => cas[uniq_id(1)], uniq_id(2) => cas[uniq_id(2)])
|
97
|
+
assert res.is_a?(Hash)
|
98
|
+
assert res[uniq_id(1)]
|
99
|
+
assert res[uniq_id(2)]
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_multi_delete_missing_with_cas_check
|
103
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
|
104
|
+
cas = connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
|
105
|
+
res = connection.delete(uniq_id(1) => cas[uniq_id(1)], uniq_id(:missing) => cas[uniq_id(2)])
|
106
|
+
assert res.is_a?(Hash)
|
107
|
+
assert res[uniq_id(1)]
|
108
|
+
refute res[uniq_id(:missing)]
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_multi_delete_with_cas_check_mismatch
|
112
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
|
113
|
+
cas = connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
|
114
|
+
|
115
|
+
assert_raises(Couchbase::Error::KeyExists) do
|
116
|
+
connection.delete(uniq_id(1) => cas[uniq_id(1)] + 1,
|
117
|
+
uniq_id(2) => cas[uniq_id(2)])
|
118
|
+
end
|
119
|
+
end
|
63
120
|
end
|
data/test/test_format.rb
CHANGED
@@ -46,29 +46,31 @@ class TestFormat < MiniTest::Unit::TestCase
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_it_raises_error_for_document_format_when_neither_to_json_nor_to_s_defined
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
if (MultiJson.respond_to?(:engine) ? MultiJson.engine : MultiJson.adapter).name =~ /Yajl$/
|
50
|
+
orig_doc = SkinyClass.new("Twoflower", "The tourist")
|
51
|
+
refute orig_doc.respond_to?(:to_s)
|
52
|
+
refute orig_doc.respond_to?(:to_json)
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :document)
|
55
|
+
assert_raises(Couchbase::Error::ValueFormat) do
|
56
|
+
connection.set(uniq_id, orig_doc)
|
57
|
+
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
class << orig_doc
|
60
|
+
def to_json
|
61
|
+
MultiJson.dump(:name => name, :role => role)
|
62
|
+
end
|
61
63
|
end
|
62
|
-
|
63
|
-
connection.set(uniq_id, orig_doc) # OK
|
64
|
+
connection.set(uniq_id, orig_doc) # OK
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
class << orig_doc
|
67
|
+
undef to_json
|
68
|
+
def to_s
|
69
|
+
MultiJson.dump(:name => name, :role => role)
|
70
|
+
end
|
69
71
|
end
|
72
|
+
connection.set(uniq_id, orig_doc) # OK
|
70
73
|
end
|
71
|
-
connection.set(uniq_id, orig_doc) # OK
|
72
74
|
end
|
73
75
|
|
74
76
|
def test_it_could_dump_arbitrary_class_using_marshal_format
|
@@ -95,4 +97,13 @@ class TestFormat < MiniTest::Unit::TestCase
|
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
100
|
+
def test_bignum_conversion
|
101
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
|
102
|
+
cas = 0xffff_ffff_ffff_ffff
|
103
|
+
assert cas.is_a?(Bignum)
|
104
|
+
assert_raises(Couchbase::Error::NotFound) do
|
105
|
+
connection.delete(uniq_id => cas)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
98
109
|
end
|
data/test/test_get.rb
CHANGED
@@ -82,7 +82,10 @@ class TestGet < MiniTest::Unit::TestCase
|
|
82
82
|
assert_equal "foo1", results[uniq_id(1)]
|
83
83
|
assert_equal "foo2", results[uniq_id(2)]
|
84
84
|
sleep(2)
|
85
|
-
|
85
|
+
assert_raises(Couchbase::Error::NotFound) do
|
86
|
+
connection.get(uniq_id(1), uniq_id(2))
|
87
|
+
end
|
88
|
+
assert connection.get(uniq_id(1), uniq_id(2), :quiet => true).compact.empty?
|
86
89
|
end
|
87
90
|
|
88
91
|
def test_multi_get_and_touch_extended
|
@@ -104,11 +107,13 @@ class TestGet < MiniTest::Unit::TestCase
|
|
104
107
|
assert results.is_a?(Hash)
|
105
108
|
assert_equal "foo1", results[uniq_id]
|
106
109
|
sleep(2)
|
107
|
-
|
110
|
+
assert_raises(Couchbase::Error::NotFound) do
|
111
|
+
connection.get(uniq_id)
|
112
|
+
end
|
108
113
|
end
|
109
114
|
|
110
115
|
def test_missing_in_quiet_mode
|
111
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
116
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
|
112
117
|
cas1 = connection.set(uniq_id(1), "foo1")
|
113
118
|
cas2 = connection.set(uniq_id(2), "foo2")
|
114
119
|
|
@@ -169,7 +174,6 @@ class TestGet < MiniTest::Unit::TestCase
|
|
169
174
|
conn.get(uniq_id) {|ret| res << ret}
|
170
175
|
handler = lambda {|ret| res << ret}
|
171
176
|
conn.get(uniq_id, &handler)
|
172
|
-
assert_equal 3, conn.seqno
|
173
177
|
end
|
174
178
|
|
175
179
|
checks = lambda do
|
@@ -198,7 +202,6 @@ class TestGet < MiniTest::Unit::TestCase
|
|
198
202
|
res = {}
|
199
203
|
connection.run do |conn|
|
200
204
|
conn.get(uniq_id(1), uniq_id(2)) {|ret| res[ret.key] = ret.value}
|
201
|
-
assert_equal 2, conn.seqno
|
202
205
|
end
|
203
206
|
|
204
207
|
assert res[uniq_id(1)]
|
@@ -231,9 +234,15 @@ class TestGet < MiniTest::Unit::TestCase
|
|
231
234
|
missing.clear
|
232
235
|
conn.get(uniq_id(:missing1), &get_handler)
|
233
236
|
conn.get(uniq_id, uniq_id(:missing2), &get_handler)
|
234
|
-
assert 3, conn.seqno
|
235
237
|
end
|
236
238
|
|
239
|
+
connection.run(&suite)
|
240
|
+
refute res.has_key?(uniq_id(:missing1))
|
241
|
+
refute res.has_key?(uniq_id(:missing2))
|
242
|
+
assert_equal [uniq_id(:missing1), uniq_id(:missing2)], missing.sort
|
243
|
+
assert_equal "foo", res[uniq_id]
|
244
|
+
|
245
|
+
connection.quiet = true
|
237
246
|
connection.run(&suite)
|
238
247
|
assert_equal "foo", res[uniq_id]
|
239
248
|
assert res.has_key?(uniq_id(:missing1)) # handler was called with nil
|
@@ -241,14 +250,6 @@ class TestGet < MiniTest::Unit::TestCase
|
|
241
250
|
assert res.has_key?(uniq_id(:missing2))
|
242
251
|
refute res[uniq_id(:missing2)]
|
243
252
|
assert_empty missing
|
244
|
-
|
245
|
-
connection.quiet = false
|
246
|
-
|
247
|
-
connection.run(&suite)
|
248
|
-
refute res.has_key?(uniq_id(:missing1))
|
249
|
-
refute res.has_key?(uniq_id(:missing2))
|
250
|
-
assert_equal [uniq_id(:missing1), uniq_id(:missing2)], missing.sort
|
251
|
-
assert_equal "foo", res[uniq_id]
|
252
253
|
end
|
253
254
|
|
254
255
|
def test_get_using_brackets
|
@@ -327,4 +328,80 @@ class TestGet < MiniTest::Unit::TestCase
|
|
327
328
|
end
|
328
329
|
end
|
329
330
|
|
331
|
+
# http://www.couchbase.com/issues/browse/RCBC-31
|
332
|
+
def test_consistent_behaviour_for_arrays
|
333
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
334
|
+
|
335
|
+
cas = connection.set(uniq_id("foo"), "foo")
|
336
|
+
connection.set(uniq_id("bar"), "bar")
|
337
|
+
|
338
|
+
assert_equal "foo", connection.get(uniq_id("foo"))
|
339
|
+
assert_equal ["foo"], connection.get([uniq_id("foo")])
|
340
|
+
assert_equal ["foo", "bar"], connection.get([uniq_id("foo"), uniq_id("bar")])
|
341
|
+
assert_equal ["foo", "bar"], connection.get(uniq_id("foo"), uniq_id("bar"))
|
342
|
+
expected = {uniq_id("foo") => ["foo", 0x00, cas]}
|
343
|
+
assert_equal expected, connection.get([uniq_id("foo")], :extended => true)
|
344
|
+
assert_raises TypeError do
|
345
|
+
connection.get([uniq_id("foo"), uniq_id("bar")], [uniq_id("foo")])
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
def test_get_with_lock_trivial
|
350
|
+
if @mock.real?
|
351
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
352
|
+
connection.set(uniq_id, "foo")
|
353
|
+
assert_equal "foo", connection.get(uniq_id, :lock => 1)
|
354
|
+
assert_raises Couchbase::Error::KeyExists do
|
355
|
+
connection.set(uniq_id, "bar")
|
356
|
+
end
|
357
|
+
sleep(2)
|
358
|
+
connection.set(uniq_id, "bar")
|
359
|
+
else
|
360
|
+
skip("implement GETL in CouchbaseMock.jar")
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
def test_multi_get_with_lock
|
365
|
+
if @mock.real?
|
366
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
367
|
+
connection.set(uniq_id(1), "foo1")
|
368
|
+
connection.set(uniq_id(2), "foo2")
|
369
|
+
assert_equal ["foo1", "foo2"], connection.get([uniq_id(1), uniq_id(2)], :lock => 1)
|
370
|
+
assert_raises Couchbase::Error::KeyExists do
|
371
|
+
connection.set(uniq_id(1), "bar")
|
372
|
+
end
|
373
|
+
assert_raises Couchbase::Error::KeyExists do
|
374
|
+
connection.set(uniq_id(2), "bar")
|
375
|
+
end
|
376
|
+
else
|
377
|
+
skip("implement GETL in CouchbaseMock.jar")
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_multi_get_with_custom_locks
|
382
|
+
if @mock.real?
|
383
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
384
|
+
connection.set(uniq_id(1), "foo1")
|
385
|
+
connection.set(uniq_id(2), "foo2")
|
386
|
+
expected = {uniq_id(1) => "foo1", uniq_id(2) => "foo2"}
|
387
|
+
assert_equal expected, connection.get({uniq_id(1) => 1, uniq_id(2) => 2}, :lock => true)
|
388
|
+
assert_raises Couchbase::Error::KeyExists do
|
389
|
+
connection.set(uniq_id(1), "foo")
|
390
|
+
end
|
391
|
+
assert_raises Couchbase::Error::KeyExists do
|
392
|
+
connection.set(uniq_id(2), "foo")
|
393
|
+
end
|
394
|
+
else
|
395
|
+
skip("implement GETL in CouchbaseMock.jar")
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
def test_multi_get_result_hash_assembling
|
400
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
401
|
+
connection.set(uniq_id(1), "foo")
|
402
|
+
connection.set(uniq_id(2), "bar")
|
403
|
+
|
404
|
+
expected = {uniq_id(1) => "foo", uniq_id(2) => "bar"}
|
405
|
+
assert_equal expected, connection.get(uniq_id(1), uniq_id(2), :assemble_hash => true)
|
406
|
+
end
|
330
407
|
end
|
data/test/test_store.rb
CHANGED
@@ -113,7 +113,6 @@ class TestStore < MiniTest::Unit::TestCase
|
|
113
113
|
connection.run do |conn|
|
114
114
|
conn.set(uniq_id("1"), "foo1") {|res| ret = res}
|
115
115
|
conn.set(uniq_id("2"), "foo2") # ignore result
|
116
|
-
assert_equal 2, conn.seqno
|
117
116
|
end
|
118
117
|
assert ret.is_a?(Couchbase::Result)
|
119
118
|
assert ret.success?
|
@@ -160,6 +159,18 @@ class TestStore < MiniTest::Unit::TestCase
|
|
160
159
|
assert_equal "barfoo", val
|
161
160
|
end
|
162
161
|
|
162
|
+
def test_set_with_prefix
|
163
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :key_prefix => "prefix:")
|
164
|
+
connection.set(uniq_id(:foo), "bar")
|
165
|
+
assert_equal "bar", connection.get(uniq_id(:foo))
|
166
|
+
expected = {uniq_id(:foo) => "bar"}
|
167
|
+
assert_equal expected, connection.get(uniq_id(:foo), :assemble_hash => true)
|
168
|
+
|
169
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :key_prefix => nil)
|
170
|
+
expected = {"prefix:#{uniq_id(:foo)}" => "bar"}
|
171
|
+
assert_equal expected, connection.get("prefix:#{uniq_id(:foo)}", :assemble_hash => true)
|
172
|
+
end
|
173
|
+
|
163
174
|
ArbitraryData = Struct.new(:baz)
|
164
175
|
|
165
176
|
def test_set_using_brackets
|
@@ -183,4 +194,23 @@ class TestStore < MiniTest::Unit::TestCase
|
|
183
194
|
EOC
|
184
195
|
end
|
185
196
|
end
|
197
|
+
|
198
|
+
def test_multi_store
|
199
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
|
200
|
+
connection.add(uniq_id(:a) => "bbb", uniq_id(:z) => "yyy")
|
201
|
+
assert_equal ["bbb", "yyy"], connection.get(uniq_id(:a), uniq_id(:z))
|
202
|
+
|
203
|
+
connection.prepend(uniq_id(:a) => "aaa", uniq_id(:z) => "xxx")
|
204
|
+
assert_equal ["aaabbb", "xxxyyy"], connection.get(uniq_id(:a), uniq_id(:z))
|
205
|
+
|
206
|
+
connection.append(uniq_id(:a) => "ccc", uniq_id(:z) => "zzz")
|
207
|
+
assert_equal ["aaabbbccc", "xxxyyyzzz"], connection.get(uniq_id(:a), uniq_id(:z))
|
208
|
+
|
209
|
+
connection.replace(uniq_id(:a) => "foo", uniq_id(:z) => "bar")
|
210
|
+
assert_equal ["foo", "bar"], connection.get(uniq_id(:a), uniq_id(:z))
|
211
|
+
|
212
|
+
res = connection.set(uniq_id(:a) => "bar", uniq_id(:z) => "foo")
|
213
|
+
assert_equal ["bar", "foo"], connection.get(uniq_id(:a), uniq_id(:z))
|
214
|
+
assert res.is_a?(Hash)
|
215
|
+
end
|
186
216
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Author:: Couchbase <info@couchbase.com>
|
2
|
-
# Copyright::
|
2
|
+
# Copyright:: 2012 Couchbase, Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,33 +17,26 @@
|
|
17
17
|
|
18
18
|
require File.join(File.dirname(__FILE__), 'setup')
|
19
19
|
|
20
|
-
class
|
20
|
+
class TestTimer < MiniTest::Unit::TestCase
|
21
21
|
|
22
22
|
def setup
|
23
|
-
@mock = start_mock
|
23
|
+
@mock = start_mock
|
24
24
|
end
|
25
25
|
|
26
26
|
def teardown
|
27
27
|
stop_mock(@mock)
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def test_initialization
|
31
31
|
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
32
|
-
|
33
|
-
|
32
|
+
num = 0
|
33
|
+
connection.run do
|
34
|
+
assert Couchbase::Timer.new(connection, 100) { num += 1}
|
35
|
+
assert connection.create_timer(100) { num += 1}
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
flushed = {}
|
38
|
-
on_node_flush = lambda{|res| flushed[res.node] = res.success?}
|
39
|
-
connection.run do |conn|
|
40
|
-
conn.flush(&on_node_flush)
|
41
|
-
end
|
42
|
-
assert_equal @mock.num_nodes, flushed.size
|
43
|
-
flushed.each do |node, res|
|
44
|
-
assert node.is_a?(String)
|
45
|
-
assert res
|
37
|
+
assert Couchbase::Timer.new(connection, 100, :periodic => true) {|t| num += 1; t.cancel}
|
38
|
+
assert connection.create_periodic_timer(100) {|t| num += 1; t.cancel}
|
46
39
|
end
|
40
|
+
assert_equal 4, num
|
47
41
|
end
|
48
|
-
|
49
42
|
end
|
data/test/test_touch.rb
CHANGED
@@ -34,7 +34,9 @@ class TestTouch < MiniTest::Unit::TestCase
|
|
34
34
|
sleep(1)
|
35
35
|
assert connection.get(uniq_id)
|
36
36
|
sleep(2)
|
37
|
-
|
37
|
+
assert_raises(Couchbase::Error::NotFound) do
|
38
|
+
connection.get(uniq_id)
|
39
|
+
end
|
38
40
|
end
|
39
41
|
|
40
42
|
def test_multi_touch
|
@@ -45,8 +47,12 @@ class TestTouch < MiniTest::Unit::TestCase
|
|
45
47
|
assert ret[uniq_id(1)]
|
46
48
|
assert ret[uniq_id(2)]
|
47
49
|
sleep(2)
|
48
|
-
|
49
|
-
|
50
|
+
assert_raises(Couchbase::Error::NotFound) do
|
51
|
+
connection.get(uniq_id(1))
|
52
|
+
end
|
53
|
+
assert_raises(Couchbase::Error::NotFound) do
|
54
|
+
connection.get(uniq_id(2))
|
55
|
+
end
|
50
56
|
end
|
51
57
|
|
52
58
|
def test_it_uses_default_ttl_for_touch
|
@@ -54,7 +60,9 @@ class TestTouch < MiniTest::Unit::TestCase
|
|
54
60
|
connection.set(uniq_id, "bar", :ttl => 10)
|
55
61
|
connection.touch(uniq_id)
|
56
62
|
sleep(2)
|
57
|
-
|
63
|
+
assert_raises(Couchbase::Error::NotFound) do
|
64
|
+
connection.get(uniq_id)
|
65
|
+
end
|
58
66
|
end
|
59
67
|
|
60
68
|
def test_it_accepts_ttl_for_get_command
|
@@ -63,7 +71,27 @@ class TestTouch < MiniTest::Unit::TestCase
|
|
63
71
|
val = connection.get(uniq_id, :ttl => 1)
|
64
72
|
assert_equal "bar", val
|
65
73
|
sleep(2)
|
66
|
-
|
74
|
+
assert_raises(Couchbase::Error::NotFound) do
|
75
|
+
connection.get(uniq_id)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_missing_in_quiet_mode
|
80
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
|
81
|
+
cas1 = connection.set(uniq_id(1), "foo1")
|
82
|
+
cas2 = connection.set(uniq_id(2), "foo2")
|
83
|
+
|
84
|
+
assert_raises(Couchbase::Error::NotFound) do
|
85
|
+
connection.touch(uniq_id(:missing), :quiet => false)
|
86
|
+
end
|
87
|
+
|
88
|
+
val = connection.touch(uniq_id(:missing))
|
89
|
+
refute(val)
|
90
|
+
|
91
|
+
ret = connection.touch(uniq_id(1), uniq_id(:missing), uniq_id(2))
|
92
|
+
assert_equal true, ret[uniq_id(1)]
|
93
|
+
assert_equal false, ret[uniq_id(:missing)]
|
94
|
+
assert_equal true, ret[uniq_id(2)]
|
67
95
|
end
|
68
96
|
|
69
97
|
end
|