Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kenaniah committed Jan 26, 2022
1 parent 301da34 commit b3814c9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Binary file added spec/lib/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions spec/lib/sidekiq-status/client_middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
describe "without :expiration parameter" do

it "sets queued status" do
expect(StubJob.perform_async arg1: 'val1').to eq(job_id)
expect(StubJob.perform_async 'arg1' => 'val1').to eq(job_id)
expect(redis.hget("sidekiq:status:#{job_id}", :status)).to eq('queued')
expect(Sidekiq::Status::queued?(job_id)).to be_truthy
end

it "sets status hash ttl" do
expect(StubJob.perform_async arg1: 'val1').to eq(job_id)
expect(StubJob.perform_async 'arg1' => 'val1').to eq(job_id)
expect(1..Sidekiq::Status::DEFAULT_EXPIRY).to cover redis.ttl("sidekiq:status:#{job_id}")
end

Expand Down Expand Up @@ -50,7 +50,7 @@
end

it "overwrites default expiry value" do
StubJob.perform_async arg1: 'val1'
StubJob.perform_async 'arg1' => 'val1'
expect((Sidekiq::Status::DEFAULT_EXPIRY+1)..huge_expiration).to cover redis.ttl("sidekiq:status:#{job_id}")
end

Expand Down
8 changes: 4 additions & 4 deletions spec/lib/sidekiq-status/server_middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
allow(SecureRandom).to receive(:hex).once.and_return(job_id)
start_server do
thread = redis_thread 4, "status_updates", "job_messages_#{job_id}"
expect(ConfirmationJob.perform_async arg1: 'val1').to eq(job_id)
expect(ConfirmationJob.perform_async 'arg1' => 'val1').to eq(job_id)
expect(thread.value).to eq([
job_id,
job_id,
Expand Down Expand Up @@ -90,7 +90,7 @@
it "sets status hash ttl" do
allow(SecureRandom).to receive(:hex).once.and_return(job_id)
start_server do
expect(StubJob.perform_async arg1: 'val1').to eq(job_id)
expect(StubJob.perform_async 'arg1' => 'val1').to eq(job_id)
end
expect(1..Sidekiq::Status::DEFAULT_EXPIRY).to cover redis.ttl("sidekiq:status:#{job_id}")
end
Expand All @@ -104,7 +104,7 @@

it "overwrites default expiry value" do
start_server(:expiration => huge_expiration) do
StubJob.perform_async arg1: 'val1'
StubJob.perform_async 'arg1' => 'val1'
end
expect((Sidekiq::Status::DEFAULT_EXPIRY-1)..huge_expiration).to cover redis.ttl("sidekiq:status:#{job_id}")
end
Expand All @@ -113,7 +113,7 @@
overwritten_expiration = huge_expiration * 100
allow_any_instance_of(StubJob).to receive(:expiration).and_return(overwritten_expiration)
start_server(:expiration => huge_expiration) do
StubJob.perform_async arg1: 'val1'
StubJob.perform_async 'arg1' => 'val1'
end
expect((huge_expiration+1)..overwritten_expiration).to cover redis.ttl("sidekiq:status:#{job_id}")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/sidekiq-status/web_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def app
get "/statuses/#{job_id}"
expect(last_response).to be_ok
expect(last_response.body).to match(/#{job_id}/)
expect(last_response.body).to match(/1,"another argument"/)
expect(last_response.body).to match(/1,"another argument"/)
expect(last_response.body).to match(/working/)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/support/test_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ def perform

class RetriedJob < StubJob

sidekiq_options 'retry' => true
sidekiq_options retry: true
sidekiq_retry_in do |count| 3 end # 3 second delay > job timeout in test suite

def perform()
def perform
Sidekiq.redis do |conn|
key = "RetriedJob_#{jid}"
unless conn.exists key
unless conn.exists(key) > 0
conn.set key, 'tried'
raise StandardError
end
Expand Down

0 comments on commit b3814c9

Please sign in to comment.