-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a worker that simulates a long running Sidekiq job (#4428)
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class SimulateLongJobWorker | ||
include Sidekiq::Worker | ||
|
||
sidekiq_options queue: :dumpworker | ||
|
||
def perform(duration_seconds) | ||
sleep(duration_seconds) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe SimulateLongJobWorker do | ||
describe '#perform' do | ||
let(:worker_instance) { described_class.new } | ||
|
||
it 'calls sleep with the specified duration' do | ||
allow(worker_instance).to receive(:sleep).with(10) | ||
worker_instance.perform(10) | ||
expect(worker_instance).to have_received(:sleep).with(10) | ||
end | ||
end | ||
end |