Sha256: 07e91d8b9204c23cb13442198d51f99ee3c8dc50e8874f95ebfbf99b99ec4eb3
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") class TestYourOwnRefreshJob < Minitest::Test include TestHelper def setup Resque::StuckQueue.config[:trigger_timeout] = 1 Resque::StuckQueue.config[:heartbeat] = 1 Resque::StuckQueue.config[:abort_on_exception] = true end def teardown Resque::StuckQueue.reset! end def test_will_trigger_with_unrefreshing_custom_heartbeat_job # it will trigger because the key will be unrefreshed, hence 'old' and will always trigger. puts "#{__method__}" Resque::StuckQueue.config[:refresh_job] = proc { nil } # does not refresh global key @triggered = false Resque::StuckQueue.config[:handler] = proc { @triggered = true } start_and_stop_loops_after(3) assert @triggered, "will trigger because global key will be old" end def test_will_fail_with_bad_custom_heartbeat_job puts "#{__method__}" begin Resque::StuckQueue.config[:refresh_job] = proc { raise 'bad proc doc' } # does not refresh global key @triggered = false Resque::StuckQueue.config[:handler] = proc { @triggered = true } start_and_stop_loops_after(3) assert false, "should not succeed with bad refresh_job" rescue assert true, "will fail with bad refresh_job" end end def test_has_settable_custom_hearbeat_job puts "#{__method__}" begin Resque::StuckQueue.config[:refresh_job] = proc { Resque.enqueue(RefreshLatestTimestamp, Resque::StuckQueue.global_key) } @triggered = false Resque::StuckQueue.config[:handler] = proc { @triggered = true } start_and_stop_loops_after(3) assert true, "should not have raised" assert @triggered, "should have triggered" rescue => e assert false, "should have succeeded with good refresh_job.\n #{e.inspect}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
resque_stuck_queue-0.0.6 | test/test_set_your_own_refresh_job.rb |