test/test_delete.rb in couchbase-jruby-client-0.1.2 vs test/test_delete.rb in couchbase-jruby-client-0.1.3
- old
+ new
@@ -17,109 +17,107 @@
require File.join(File.dirname(__FILE__), 'setup')
class TestStore < MiniTest::Test
- def setup
- @mock = start_mock
- end
-
- def teardown
- stop_mock(@mock)
- end
-
def test_trivial_delete
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
- connection.set(uniq_id, "bar")
- assert connection.delete(uniq_id)
+ cb.set(uniq_id, "bar")
+ assert cb.delete(uniq_id)
assert_raises(Couchbase::Error::NotFound) do
- connection.delete(uniq_id)
+ cb.delete(uniq_id)
end
end
def test_delete_missing
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
assert_raises(Couchbase::Error::NotFound) do
- connection.delete(uniq_id(:missing))
+ cb.delete(uniq_id(:missing))
end
- refute connection.delete(uniq_id(:missing), :quiet => true)
- refute connection.quiet?
- connection.quiet = true
- refute connection.delete(uniq_id(:missing))
+ refute cb.delete(uniq_id(:missing), :quiet => true)
+ refute cb.quiet?
+ cb.quiet = true
+ refute cb.delete(uniq_id(:missing))
end
def test_delete_with_cas
skip
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
- cas = connection.set(uniq_id, "bar")
+ cas = cb.set(uniq_id, "bar")
missing_cas = cas - 1
assert_raises(Couchbase::Error::KeyExists) do
- connection.delete(uniq_id, :cas => missing_cas)
+ cb.delete(uniq_id, :cas => missing_cas)
end
- assert connection.delete(uniq_id, :cas => cas)
+ assert cb.delete(uniq_id, :cas => cas)
end
def test_allow_fixnum_as_cas_parameter
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
- cas = connection.set(uniq_id, "bar")
- assert connection.delete(uniq_id, cas)
+ cas = cb.set(uniq_id, "bar")
+ assert cb.delete(uniq_id, cas)
end
def test_delete_with_prefix
skip
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :key_prefix => "prefix:")
- connection.set(uniq_id(:foo), "bar")
- assert connection.delete(uniq_id(:foo))
+ cb.set(uniq_id(:foo), "bar")
+ assert cb.delete(uniq_id(:foo))
assert_raises(Couchbase::Error::NotFound) do
- connection.get(uniq_id(:foo))
+ cb.get(uniq_id(:foo))
end
end
def test_simple_multi_delete
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
- connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
- res = connection.delete(uniq_id(1), uniq_id(2))
+ cb.quiet = true
+ cb.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
+ res = cb.delete(uniq_id(1), uniq_id(2))
assert res.is_a?(Hash)
assert res[uniq_id(1)]
assert res[uniq_id(2)]
+ ensure
+ cb.quiet = false
end
def test_simple_multi_delete_missing
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
- connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
- res = connection.delete(uniq_id(1), uniq_id(:missing), :quiet => true)
+ cb.quiet = true
+ cb.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
+ res = cb.delete(uniq_id(1), uniq_id(:missing), :quiet => true)
assert res.is_a?(Hash)
assert res[uniq_id(1)]
refute res[uniq_id(:missing)]
+ ensure
+ cb.quiet = false
end
def test_multi_delete_with_cas_check
skip
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
- cas = connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
- res = connection.delete(uniq_id(1) => cas[uniq_id(1)], uniq_id(2) => cas[uniq_id(2)])
+ cb.quiet = true
+ cas = cb.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
+ res = cb.delete(uniq_id(1) => cas[uniq_id(1)], uniq_id(2) => cas[uniq_id(2)])
assert res.is_a?(Hash)
assert res[uniq_id(1)]
assert res[uniq_id(2)]
+ ensure
+ cb.quiet = false
end
def test_multi_delete_missing_with_cas_check
skip
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
- cas = connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
- res = connection.delete(uniq_id(1) => cas[uniq_id(1)], uniq_id(:missing) => cas[uniq_id(2)])
+ cb.quiet = true
+ cas = cb.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
+ res = cb.delete(uniq_id(1) => cas[uniq_id(1)], uniq_id(:missing) => cas[uniq_id(2)])
assert res.is_a?(Hash)
assert res[uniq_id(1)]
refute res[uniq_id(:missing)]
+ ensure
+ cb.quiet = false
end
def test_multi_delete_with_cas_check_mismatch
skip
- connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :quiet => true)
- cas = connection.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
+ cb.quiet = true
+ cas = cb.set(uniq_id(1) => "bar", uniq_id(2) => "foo")
assert_raises(Couchbase::Error::KeyExists) do
- connection.delete(uniq_id(1) => cas[uniq_id(1)] + 1,
+ cb.delete(uniq_id(1) => cas[uniq_id(1)] + 1,
uniq_id(2) => cas[uniq_id(2)])
end
+ ensure
+ cb.quiet = false
end
end