Sha256: 98dbcb425629310b21c128f00f707810f5a9e2ee47c9a0882da680564a53e893
Contents?: true
Size: 837 Bytes
Versions: 3
Compression:
Stored size: 837 Bytes
Contents
require "#{File.dirname(__FILE__)}/../test_helper" class LockTest < Test::Unit::TestCase KEY = "memcached_test" LOCK = "lock:#{KEY}" def setup CACHE.delete KEY CACHE.delete LOCK end def test_unlocked assert_nil CACHE.get(KEY) assert_nil CACHE.get(LOCK) assert_nothing_raised do CACHE.lock(KEY) { "A" } end assert_nil CACHE.get(LOCK) assert_equal("A", CACHE.get(KEY)) end def test_locked CACHE.set LOCK, "Bogus" assert_raises Interlock::LockAcquisitionError do CACHE.lock(KEY, 30, 2) { "A" } end assert_equal("Bogus", CACHE.get(LOCK)) assert_nil CACHE.get(KEY) end def test_ensure_lock_release assert_raises RuntimeError do CACHE.lock(KEY) { raise } end assert_nil CACHE.get(LOCK) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
interlock-1.4 | test/unit/lock_test.rb |
interlock-1.2 | test/unit/lock_test.rb |
interlock-1.3 | test/unit/lock_test.rb |