test/lib/worker_test.rb in sidekiq-lock-0.0.1 vs test/lib/worker_test.rb in sidekiq-lock-0.2.0
- old
+ new
@@ -2,12 +2,27 @@
module Sidekiq
module Lock
describe Worker do
+ after { set_lock_variable! }
+
it 'sets lock method that points to thread variable' do
- Thread.current[Sidekiq::Lock::THREAD_KEY] = "test"
+ set_lock_variable! "test"
assert_equal "test", LockWorker.new.lock
+ end
+
+ it 'allows method name configuration' do
+ Sidekiq.lock_method = :custom_lock_name
+
+ class WorkerWithCustomLockName
+ include Sidekiq::Worker
+ include Sidekiq::Lock::Worker
+ end
+
+ set_lock_variable! "custom_name"
+
+ assert_equal "custom_name", WorkerWithCustomLockName.new.custom_lock_name
end
end
end
end