couchbase-jruby-client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- 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_stats.rb
CHANGED
@@ -19,39 +19,24 @@ require File.join(File.dirname(__FILE__), 'setup')
|
|
19
19
|
|
20
20
|
class TestStats < MiniTest::Test
|
21
21
|
|
22
|
-
def setup
|
23
|
-
@mock = start_mock(:num_nodes => 4)
|
24
|
-
end
|
25
|
-
|
26
|
-
def teardown
|
27
|
-
stop_mock(@mock)
|
28
|
-
end
|
29
|
-
|
30
22
|
def test_trivial_stats_without_argument
|
31
|
-
|
32
|
-
stats = connection.stats
|
23
|
+
stats = cb.stats
|
33
24
|
assert stats.is_a?(Hash)
|
34
25
|
assert stats.has_key?("pid")
|
35
26
|
key, info = stats.first
|
36
27
|
assert key.is_a?(String)
|
37
28
|
assert info.is_a?(Hash)
|
38
|
-
assert_equal
|
29
|
+
assert_equal 1, info.size
|
39
30
|
end
|
40
31
|
|
41
32
|
def test_stats_with_argument
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
assert info.is_a?(Hash)
|
50
|
-
assert_equal @mock.num_nodes, info.size
|
51
|
-
else
|
52
|
-
# FIXME
|
53
|
-
skip("make CouchbaseMock.jar STATS more real-life")
|
54
|
-
end
|
33
|
+
stats = cb.stats("memory")
|
34
|
+
assert stats.is_a?(Hash)
|
35
|
+
assert stats.has_key?("mem_used")
|
36
|
+
key, info = stats.first
|
37
|
+
assert key.is_a?(String)
|
38
|
+
assert info.is_a?(Hash)
|
39
|
+
assert_equal 1, info.size
|
55
40
|
end
|
56
41
|
|
57
42
|
end
|
data/test/test_store.rb
CHANGED
@@ -19,98 +19,84 @@ require File.join(File.dirname(__FILE__), 'setup')
|
|
19
19
|
|
20
20
|
class TestStore < 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_trivial_set
|
31
|
-
|
32
|
-
cas = connection.set(uniq_id, "bar")
|
23
|
+
cas = cb.set(uniq_id, "bar")
|
33
24
|
assert(cas > 0)
|
34
25
|
end
|
35
26
|
|
36
27
|
def test_set_with_cas
|
37
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
38
28
|
|
39
|
-
cas1 =
|
29
|
+
cas1 = cb.set(uniq_id, "bar1")
|
40
30
|
assert cas1 > 0
|
41
31
|
|
42
32
|
assert_raises(Couchbase::Error::KeyExists) do
|
43
|
-
|
33
|
+
cb.set(uniq_id, "bar2", :cas => cas1+1)
|
44
34
|
end
|
45
35
|
|
46
|
-
cas2 =
|
36
|
+
cas2 = cb.set(uniq_id, "bar2", :cas => cas1)
|
47
37
|
assert cas2 > 0
|
48
38
|
refute_equal cas2, cas1
|
49
39
|
|
50
|
-
cas3 =
|
40
|
+
cas3 = cb.set(uniq_id, "bar3")
|
51
41
|
assert cas3 > 0
|
52
42
|
refute_equal cas3, cas2
|
53
43
|
refute_equal cas3, cas1
|
54
44
|
end
|
55
45
|
|
56
46
|
def test_add
|
57
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
58
47
|
|
59
|
-
cas1 =
|
48
|
+
cas1 = cb.add(uniq_id, "bar")
|
60
49
|
assert cas1 > 0
|
61
50
|
|
62
51
|
assert_raises(Couchbase::Error::KeyExists) do
|
63
|
-
|
52
|
+
cb.add(uniq_id, "bar")
|
64
53
|
end
|
65
54
|
|
66
55
|
assert_raises(Couchbase::Error::KeyExists) do
|
67
|
-
|
56
|
+
cb.add(uniq_id, "bar", :cas => cas1)
|
68
57
|
end
|
69
58
|
end
|
70
59
|
|
71
60
|
def test_replace
|
72
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
73
61
|
|
74
62
|
assert_raises(Couchbase::Error::NotFound) do
|
75
|
-
|
63
|
+
cb.replace(uniq_id, "bar")
|
76
64
|
end
|
77
65
|
|
78
|
-
cas1 =
|
66
|
+
cas1 = cb.set(uniq_id, "bar")
|
79
67
|
assert cas1 > 0
|
80
68
|
|
81
|
-
|
69
|
+
cb.replace(uniq_id, "bar")
|
82
70
|
end
|
83
71
|
|
84
72
|
def test_acceptable_keys
|
85
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
86
73
|
|
87
|
-
cas =
|
74
|
+
cas = cb.set(uniq_id.to_sym, "bar")
|
88
75
|
assert cas > 0
|
89
76
|
|
90
|
-
cas =
|
77
|
+
cas = cb.set(uniq_id.to_s, "bar")
|
91
78
|
assert cas > 0
|
92
79
|
|
93
80
|
assert_raises(TypeError) do
|
94
|
-
|
81
|
+
cb.set(nil, "bar")
|
95
82
|
end
|
96
83
|
|
97
84
|
obj = {:foo => "bar", :baz => 1}
|
98
85
|
assert_raises(TypeError) do
|
99
|
-
|
86
|
+
cb.set(obj, "bar")
|
100
87
|
end
|
101
88
|
|
102
89
|
class << obj
|
103
90
|
alias :to_str :to_s
|
104
91
|
end
|
105
92
|
|
106
|
-
|
93
|
+
cb.set(obj, "bar")
|
107
94
|
assert cas > 0
|
108
95
|
end
|
109
96
|
|
110
97
|
def test_asynchronous_set
|
111
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
112
98
|
ret = nil
|
113
|
-
|
99
|
+
cb.run do |conn|
|
114
100
|
conn.set(uniq_id("1"), "foo1") {|res| ret = res}
|
115
101
|
conn.set(uniq_id("2"), "foo2") # ignore result
|
116
102
|
end
|
@@ -123,69 +109,72 @@ class TestStore < MiniTest::Test
|
|
123
109
|
end
|
124
110
|
|
125
111
|
def test_it_raises_error_when_appending_or_prepending_to_missing_key
|
126
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
127
112
|
|
128
113
|
assert_raises(Couchbase::Error::NotStored) do
|
129
|
-
|
114
|
+
cb.append(uniq_id(:missing), "foo")
|
130
115
|
end
|
131
116
|
|
132
117
|
assert_raises(Couchbase::Error::NotStored) do
|
133
|
-
|
118
|
+
cb.prepend(uniq_id(:missing), "foo")
|
134
119
|
end
|
135
120
|
end
|
136
121
|
|
137
122
|
def test_append
|
138
|
-
|
123
|
+
skip 'Plain encoding isnt working correctly'
|
124
|
+
cb.default_format = :plain
|
139
125
|
|
140
|
-
cas1 =
|
126
|
+
cas1 = cb.set(uniq_id, "foo")
|
141
127
|
assert cas1 > 0
|
142
|
-
cas2 =
|
128
|
+
cas2 = cb.append(uniq_id, "bar")
|
143
129
|
assert cas2 > 0
|
144
130
|
refute_equal cas2, cas1
|
145
131
|
|
146
|
-
val =
|
132
|
+
val = cb.get(uniq_id)
|
147
133
|
assert_equal "foobar", val
|
134
|
+
ensure
|
135
|
+
cb.default_format = :document
|
148
136
|
end
|
149
137
|
|
150
138
|
def test_prepend
|
151
|
-
|
139
|
+
skip 'Plain encoding isnt working correctly'
|
140
|
+
cb.default_format = :plain
|
152
141
|
|
153
|
-
cas1 =
|
142
|
+
cas1 = cb.set(uniq_id, "foo")
|
154
143
|
assert cas1 > 0
|
155
|
-
cas2 =
|
144
|
+
cas2 = cb.prepend(uniq_id, "bar")
|
156
145
|
assert cas2 > 0
|
157
146
|
refute_equal cas2, cas1
|
158
147
|
|
159
|
-
val =
|
148
|
+
val = cb.get(uniq_id)
|
160
149
|
assert_equal "barfoo", val
|
150
|
+
ensure
|
151
|
+
cb.default_format = :document
|
161
152
|
end
|
162
153
|
|
163
154
|
def test_set_with_prefix
|
164
155
|
skip
|
165
156
|
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :key_prefix => "prefix:")
|
166
|
-
|
167
|
-
assert_equal "bar",
|
157
|
+
cb.set(uniq_id(:foo), "bar")
|
158
|
+
assert_equal "bar", cb.get(uniq_id(:foo))
|
168
159
|
expected = {uniq_id(:foo) => "bar"}
|
169
|
-
assert_equal expected,
|
160
|
+
assert_equal expected, cb.get(uniq_id(:foo), :assemble_hash => true)
|
170
161
|
|
171
162
|
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :key_prefix => nil)
|
172
163
|
expected = {"prefix:#{uniq_id(:foo)}" => "bar"}
|
173
|
-
assert_equal expected,
|
164
|
+
assert_equal expected, cb.get("prefix:#{uniq_id(:foo)}", :assemble_hash => true)
|
174
165
|
end
|
175
166
|
|
176
167
|
ArbitraryData = Struct.new(:baz)
|
177
168
|
|
178
169
|
def test_set_using_brackets
|
179
|
-
|
180
|
-
|
181
|
-
connection[uniq_id(1)] = "foo"
|
182
|
-
val = connection.get(uniq_id(1))
|
170
|
+
cb[uniq_id(1)] = "foo"
|
171
|
+
val = cb.get(uniq_id(1))
|
183
172
|
assert_equal "foo", val
|
184
173
|
|
185
174
|
# if RUBY_VERSION =~ /^1\.9/
|
186
175
|
# eval <<-EOC
|
187
176
|
# connection[uniq_id(3), :format => :marshal] = ArbitraryData.new("thing")
|
188
|
-
# val =
|
177
|
+
# val = cb.get(uniq_id(3))
|
189
178
|
# assert val.is_a?(ArbitraryData)
|
190
179
|
# assert_equal "thing", val.baz
|
191
180
|
# EOC
|
@@ -193,21 +182,23 @@ class TestStore < MiniTest::Test
|
|
193
182
|
end
|
194
183
|
|
195
184
|
def test_multi_store
|
196
|
-
|
197
|
-
|
198
|
-
assert_equal ["bbb", "yyy"],
|
185
|
+
cb.default_format = :plain
|
186
|
+
cb.add(uniq_id(:a) => "bbb", uniq_id(:z) => "yyy")
|
187
|
+
assert_equal ["bbb", "yyy"], cb.get(uniq_id(:a), uniq_id(:z))
|
199
188
|
|
200
|
-
#
|
201
|
-
# assert_equal ["aaabbb", "xxxyyy"],
|
189
|
+
# cb.prepend(uniq_id(:a) => "aaa", uniq_id(:z) => "xxx")
|
190
|
+
# assert_equal ["aaabbb", "xxxyyy"], cb.get(uniq_id(:a), uniq_id(:z))
|
202
191
|
|
203
|
-
#
|
204
|
-
# assert_equal ["aaabbbccc", "xxxyyyzzz"],
|
192
|
+
# cb.append(uniq_id(:a) => "ccc", uniq_id(:z) => "zzz")
|
193
|
+
# assert_equal ["aaabbbccc", "xxxyyyzzz"], cb.get(uniq_id(:a), uniq_id(:z))
|
205
194
|
|
206
|
-
#
|
207
|
-
# assert_equal ["foo", "bar"],
|
195
|
+
# cb.replace(uniq_id(:a) => "foo", uniq_id(:z) => "bar")
|
196
|
+
# assert_equal ["foo", "bar"], cb.get(uniq_id(:a), uniq_id(:z))
|
208
197
|
|
209
|
-
res =
|
210
|
-
assert_equal ["bar", "foo"],
|
198
|
+
res = cb.set(uniq_id(:a) => "bar", uniq_id(:z) => "foo")
|
199
|
+
assert_equal ["bar", "foo"], cb.get(uniq_id(:a), uniq_id(:z))
|
211
200
|
assert res.is_a?(Hash)
|
201
|
+
ensure
|
202
|
+
cb.default_format = :document
|
212
203
|
end
|
213
204
|
end
|
data/test/test_timer.rb
CHANGED
@@ -19,24 +19,15 @@ require File.join(File.dirname(__FILE__), 'setup')
|
|
19
19
|
|
20
20
|
class TestTimer < 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_initialization
|
31
23
|
skip
|
32
|
-
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
33
24
|
num = 0
|
34
|
-
|
25
|
+
cb.run do
|
35
26
|
assert Couchbase::Timer.new(connection, 100) { num += 1}
|
36
|
-
assert
|
27
|
+
assert cb.create_timer(100) { num += 1}
|
37
28
|
|
38
29
|
assert Couchbase::Timer.new(connection, 100, :periodic => true) {|t| num += 1; t.cancel}
|
39
|
-
assert
|
30
|
+
assert cb.create_periodic_timer(100) {|t| num += 1; t.cancel}
|
40
31
|
end
|
41
32
|
assert_equal 4, num
|
42
33
|
end
|
data/test/test_touch.rb
CHANGED
@@ -19,79 +19,72 @@ require File.join(File.dirname(__FILE__), 'setup')
|
|
19
19
|
|
20
20
|
class TestTouch < 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_trivial_touch
|
31
|
-
|
32
|
-
|
33
|
-
connection.touch(uniq_id, :ttl => 2)
|
23
|
+
cb.set(uniq_id, "bar", :ttl => 1)
|
24
|
+
cb.touch(uniq_id, :ttl => 2)
|
34
25
|
sleep(1)
|
35
|
-
assert
|
26
|
+
assert cb.get(uniq_id)
|
36
27
|
sleep(2)
|
37
28
|
assert_raises(Couchbase::Error::NotFound) do
|
38
|
-
|
29
|
+
cb.get(uniq_id)
|
39
30
|
end
|
40
31
|
end
|
41
32
|
|
42
33
|
def test_multi_touch
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
ret = connection.touch(uniq_id(1) => 1, uniq_id(2) => 1)
|
34
|
+
cb.set(uniq_id(1), "bar")
|
35
|
+
cb.set(uniq_id(2), "baz")
|
36
|
+
ret = cb.touch(uniq_id(1) => 1, uniq_id(2) => 1)
|
47
37
|
assert ret[uniq_id(1)]
|
48
38
|
assert ret[uniq_id(2)]
|
49
39
|
sleep(2)
|
50
40
|
assert_raises(Couchbase::Error::NotFound) do
|
51
|
-
|
41
|
+
cb.get(uniq_id(1))
|
52
42
|
end
|
53
43
|
assert_raises(Couchbase::Error::NotFound) do
|
54
|
-
|
44
|
+
cb.get(uniq_id(2))
|
55
45
|
end
|
56
46
|
end
|
57
47
|
|
58
48
|
def test_it_uses_default_ttl_for_touch
|
59
|
-
|
60
|
-
|
61
|
-
|
49
|
+
cb.default_ttl = 1
|
50
|
+
cb.set(uniq_id, "bar", :ttl => 10)
|
51
|
+
cb.touch(uniq_id)
|
62
52
|
sleep(2)
|
63
53
|
assert_raises(Couchbase::Error::NotFound) do
|
64
|
-
|
54
|
+
cb.get(uniq_id)
|
65
55
|
end
|
56
|
+
ensure
|
57
|
+
cb.default_ttl = 0
|
66
58
|
end
|
67
59
|
|
68
60
|
def test_it_accepts_ttl_for_get_command
|
69
|
-
|
70
|
-
|
71
|
-
val = connection.get(uniq_id, :ttl => 1)
|
61
|
+
cb.set(uniq_id, "bar", :ttl => 10)
|
62
|
+
val = cb.get(uniq_id, :ttl => 1)
|
72
63
|
assert_equal "bar", val
|
73
64
|
sleep(2)
|
74
65
|
assert_raises(Couchbase::Error::NotFound) do
|
75
|
-
|
66
|
+
cb.get(uniq_id)
|
76
67
|
end
|
77
68
|
end
|
78
69
|
|
79
70
|
def test_missing_in_quiet_mode
|
80
|
-
|
81
|
-
cas1 =
|
82
|
-
cas2 =
|
71
|
+
cb.quiet = true
|
72
|
+
cas1 = cb.set(uniq_id(1), "foo1")
|
73
|
+
cas2 = cb.set(uniq_id(2), "foo2")
|
83
74
|
|
84
75
|
assert_raises(Couchbase::Error::NotFound) do
|
85
|
-
|
76
|
+
cb.touch(uniq_id(:missing), :quiet => false)
|
86
77
|
end
|
87
78
|
|
88
|
-
val =
|
79
|
+
val = cb.touch(uniq_id(:missing))
|
89
80
|
refute(val)
|
90
81
|
|
91
|
-
ret =
|
82
|
+
ret = cb.touch(uniq_id(1), uniq_id(:missing), uniq_id(2))
|
92
83
|
assert_equal true, ret[uniq_id(1)]
|
93
84
|
assert_equal false, ret[uniq_id(:missing)]
|
94
85
|
assert_equal true, ret[uniq_id(2)]
|
86
|
+
ensure
|
87
|
+
cb.quiet = false
|
95
88
|
end
|
96
89
|
|
97
90
|
end
|
data/test/test_unlock.rb
CHANGED
@@ -19,103 +19,70 @@ require File.join(File.dirname(__FILE__), 'setup')
|
|
19
19
|
|
20
20
|
class TestUnlock < 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_trivial_unlock
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
assert_raises Couchbase::Error::KeyExists do
|
36
|
-
connection.set(uniq_id, "bar")
|
37
|
-
end
|
38
|
-
assert connection.unlock(uniq_id, :cas => cas)
|
39
|
-
connection.set(uniq_id, "bar")
|
40
|
-
else
|
41
|
-
skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
|
23
|
+
cb.set(uniq_id, "foo")
|
24
|
+
_, _, cas = cb.get(uniq_id, :lock => true, :extended => true)
|
25
|
+
assert_raises Couchbase::Error::KeyExists do
|
26
|
+
cb.set(uniq_id, "bar")
|
42
27
|
end
|
28
|
+
assert cb.unlock(uniq_id, :cas => cas)
|
29
|
+
cb.set(uniq_id, "bar")
|
43
30
|
end
|
44
31
|
|
45
32
|
def test_alternative_syntax_for_single_key
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
assert_raises Couchbase::Error::KeyExists do
|
51
|
-
connection.set(uniq_id, "bar")
|
52
|
-
end
|
53
|
-
assert connection.unlock(uniq_id, cas)
|
54
|
-
connection.set(uniq_id, "bar")
|
55
|
-
else
|
56
|
-
skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
|
33
|
+
cb.set(uniq_id, "foo")
|
34
|
+
_, _, cas = cb.get(uniq_id, :lock => true, :extended => true)
|
35
|
+
assert_raises Couchbase::Error::KeyExists do
|
36
|
+
cb.set(uniq_id, "bar")
|
57
37
|
end
|
38
|
+
assert cb.unlock(uniq_id, cas)
|
39
|
+
cb.set(uniq_id, "bar")
|
58
40
|
end
|
59
41
|
|
60
42
|
def test_multiple_unlock
|
61
43
|
skip
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
assert_raises Couchbase::Error::KeyExists do
|
71
|
-
connection.set(uniq_id(2), "bar")
|
72
|
-
end
|
73
|
-
ret = connection.unlock(uniq_id(1) => info[uniq_id(1)][2],
|
74
|
-
uniq_id(2) => info[uniq_id(2)][2])
|
75
|
-
assert ret[uniq_id(1)]
|
76
|
-
assert ret[uniq_id(2)]
|
77
|
-
connection.set(uniq_id(1), "bar")
|
78
|
-
connection.set(uniq_id(2), "bar")
|
79
|
-
else
|
80
|
-
skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
|
44
|
+
cb.set(uniq_id(1), "foo")
|
45
|
+
cb.set(uniq_id(2), "foo")
|
46
|
+
info = cb.get(uniq_id(1), uniq_id(2), :lock => true, :extended => true)
|
47
|
+
assert_raises Couchbase::Error::KeyExists do
|
48
|
+
cb.set(uniq_id(1), "bar")
|
49
|
+
end
|
50
|
+
assert_raises Couchbase::Error::KeyExists do
|
51
|
+
cb.set(uniq_id(2), "bar")
|
81
52
|
end
|
53
|
+
ret = cb.unlock(uniq_id(1) => info[uniq_id(1)][2],
|
54
|
+
uniq_id(2) => info[uniq_id(2)][2])
|
55
|
+
assert ret[uniq_id(1)]
|
56
|
+
assert ret[uniq_id(2)]
|
57
|
+
cb.set(uniq_id(1), "bar")
|
58
|
+
cb.set(uniq_id(2), "bar")
|
82
59
|
end
|
83
60
|
|
84
61
|
def test_quiet_mode
|
85
62
|
skip
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
assert_raises Couchbase::Error::NotFound do
|
91
|
-
connection.unlock(uniq_id(:missing), :cas => 0xdeadbeef)
|
92
|
-
end
|
93
|
-
keys = {
|
94
|
-
uniq_id => cas,
|
95
|
-
uniq_id(:missing) => 0xdeadbeef
|
96
|
-
}
|
97
|
-
ret = connection.unlock(keys, :quiet => true)
|
98
|
-
assert ret[uniq_id]
|
99
|
-
refute ret[uniq_id(:missing)]
|
100
|
-
else
|
101
|
-
skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
|
63
|
+
cb.set(uniq_id, "foo")
|
64
|
+
_, _, cas = cb.get(uniq_id, :lock => true, :extended => true)
|
65
|
+
assert_raises Couchbase::Error::NotFound do
|
66
|
+
cb.unlock(uniq_id(:missing), :cas => 0xdeadbeef)
|
102
67
|
end
|
68
|
+
keys = {
|
69
|
+
uniq_id => cas,
|
70
|
+
uniq_id(:missing) => 0xdeadbeef
|
71
|
+
}
|
72
|
+
ret = cb.unlock(keys, :quiet => true)
|
73
|
+
assert ret[uniq_id]
|
74
|
+
refute ret[uniq_id(:missing)]
|
103
75
|
end
|
104
76
|
|
105
77
|
def test_tmp_failure
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
assert_raises Couchbase::Error::TemporaryFail do
|
115
|
-
connection.unlock(uniq_id(2), cas2)
|
116
|
-
end
|
117
|
-
else
|
118
|
-
skip("GETL and UNL aren't implemented in CouchbaseMock.jar yet")
|
78
|
+
cas1 = cb.set(uniq_id(1), "foo")
|
79
|
+
cas2 = cb.set(uniq_id(2), "foo")
|
80
|
+
cb.get(uniq_id(1), :lock => true) # get with lock will update CAS
|
81
|
+
assert_raises Couchbase::Error::TemporaryFail do
|
82
|
+
cb.unlock(uniq_id(1), cas1)
|
83
|
+
end
|
84
|
+
assert_raises Couchbase::Error::TemporaryFail do
|
85
|
+
cb.unlock(uniq_id(2), cas2)
|
119
86
|
end
|
120
87
|
end
|
121
88
|
end
|