2015-12-31 18:33:35 -05:00
|
|
|
# frozen_string_literal: true
|
2022-03-03 15:50:03 -05:00
|
|
|
|
|
|
|
require_relative "helper"
|
|
|
|
require "sidekiq/util"
|
2015-07-12 13:51:34 -04:00
|
|
|
|
2018-12-03 16:24:37 -05:00
|
|
|
class TestUtil < Minitest::Test
|
2015-07-12 13:51:34 -04:00
|
|
|
class Helpers
|
|
|
|
include Sidekiq::Util
|
|
|
|
end
|
|
|
|
|
2018-01-11 12:37:55 -05:00
|
|
|
def test_event_firing
|
2019-02-28 17:07:27 -05:00
|
|
|
before_handlers = Sidekiq.options[:lifecycle_events][:startup]
|
|
|
|
begin
|
|
|
|
Sidekiq.options[:lifecycle_events][:startup] = [proc { raise "boom" }]
|
|
|
|
h = Helpers.new
|
|
|
|
h.fire_event(:startup)
|
2018-01-11 12:37:55 -05:00
|
|
|
|
2019-02-28 17:07:27 -05:00
|
|
|
Sidekiq.options[:lifecycle_events][:startup] = [proc { raise "boom" }]
|
|
|
|
assert_raises RuntimeError do
|
|
|
|
h.fire_event(:startup, reraise: true)
|
|
|
|
end
|
|
|
|
ensure
|
|
|
|
Sidekiq.options[:lifecycle_events][:startup] = before_handlers
|
2017-12-08 16:24:21 -05:00
|
|
|
end
|
2015-07-12 13:51:34 -04:00
|
|
|
end
|
|
|
|
end
|