Skip to content

Commit

Permalink
Add a worker that simulates a long running Sidekiq job (#4428)
Browse files Browse the repository at this point in the history
  • Loading branch information
zwolf authored Feb 5, 2025
1 parent 3cb6280 commit 3806951
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/workers/simulate_long_job_worker.rb
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
15 changes: 15 additions & 0 deletions spec/workers/simulate_long_job_worker_spec.rb
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

0 comments on commit 3806951

Please sign in to comment.