Skip to content

Commit

Permalink
fix rubocop (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremiahChurch authored Mar 13, 2023
1 parent dbe9c55 commit 7026868
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 82 deletions.
32 changes: 16 additions & 16 deletions spec/sidekiq/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
describe Sidekiq::SortedEntry::UniqueExtension do
it "deletes uniqueness lock on delete" do
expect(JustAWorker.perform_in(60 * 60 * 3, "foo" => "bar")).to be_truthy
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])

Sidekiq::ScheduledSet.new.each(&:delete)
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])

expect(JustAWorker.perform_in(60 * 60 * 3, "boo" => "far")).to be_truthy
end

it "deletes uniqueness lock on remove_job" do
expect(JustAWorker.perform_in(60 * 60 * 3, "foo" => "bar")).to be_truthy
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])

Sidekiq::ScheduledSet.new.each do |entry|
entry.send(:remove_job) do |message|
Expand All @@ -44,7 +44,7 @@
)
end
end
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
expect(JustAWorker.perform_in(60 * 60 * 3, "boo" => "far")).to be_truthy
end
end
Expand All @@ -53,57 +53,57 @@
describe Sidekiq::JobRecord::UniqueExtension do
it "deletes uniqueness lock on delete" do
jid = JustAWorker.perform_async("roo" => "baf")
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
Sidekiq::Queue.new("testqueue").find_job(jid).delete
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end
end
else
describe Sidekiq::Job::UniqueExtension do
it "deletes uniqueness lock on delete" do
jid = JustAWorker.perform_async("roo" => "baf")
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
Sidekiq::Queue.new("testqueue").find_job(jid).delete
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end
end
end

describe Sidekiq::Queue::UniqueExtension do
it "deletes uniqueness locks on clear" do
JustAWorker.perform_async("oob" => "far")
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
Sidekiq::Queue.new("testqueue").clear
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end
end

describe Sidekiq::JobSet::UniqueExtension do
it "deletes uniqueness locks on clear" do
JustAWorker.perform_in(60 * 60 * 3, "roo" => "fab")
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
Sidekiq::JobSet.new("schedule").clear
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end
end

describe Sidekiq::ScheduledSet::UniqueExtension do
it "deletes uniqueness locks on clear" do
JustAWorker.perform_in(60 * 60 * 3, "roo" => "fab")
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
Sidekiq::ScheduledSet.new.clear
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end

it "deletes uniqueness locks on delete_by_score" do
JustAWorker.perform_in(60 * 60 * 3, "roo" => "fab")
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
scheduled_set = Sidekiq::ScheduledSet.new
scheduled_set.each do |job|
scheduled_set.delete(job.score, job.jid)
end

expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end
end
end
4 changes: 2 additions & 2 deletions spec/sidekiq_unique_jobs/batch_delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
call

locks.all? do |lock|
expect(lock.all_jids).to match_array([])
expect(unique_keys).to match_array([])
expect(lock.all_jids).to eq([])
expect(unique_keys).to eq([])
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/sidekiq_unique_jobs/changelog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
let(:count) { nil }

context "when no entries exist" do
it { is_expected.to match_array([]) }
it { is_expected.to eq([]) }
end

context "when entries exist" do
Expand All @@ -174,13 +174,13 @@
}
end

it { is_expected.to match_array([locked_entry, queued_entry]) }
it { is_expected.to contain_exactly(locked_entry, queued_entry) }

context "when given count 1" do
let(:count) { 1 }

# count only is considered per iteration, this would have iterated twice
it { is_expected.to match_array([locked_entry, queued_entry]) }
it { is_expected.to contain_exactly(locked_entry, queued_entry) }
end
end
end
Expand All @@ -193,7 +193,7 @@
let(:page_size) { 1 }

context "when no entries exist" do
it { is_expected.to match_array([0, 0, []]) }
it { is_expected.to contain_exactly(0, 0, []) }
end

context "when entries exist" do
Expand Down Expand Up @@ -221,7 +221,7 @@
}
end

it { is_expected.to match_array([2, anything, a_collection_including(kind_of(Hash))]) }
it { is_expected.to contain_exactly(2, anything, a_collection_including(kind_of(Hash))) }
end
end
end
2 changes: 1 addition & 1 deletion spec/sidekiq_unique_jobs/digests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

it "deletes all matching digests" do
expect(delete_by_pattern).to be_a(Integer)
expect(digests.entries).to match_array([])
expect(digests.entries).to match_array([]) # rubocop:todo RSpec/MatchArray
end

it "logs performance info" do
Expand Down
2 changes: 1 addition & 1 deletion spec/sidekiq_unique_jobs/lock/base_lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe SidekiqUniqueJobs::Lock::BaseLock do
let(:lock) { described_class.new(item, callback) }
let(:callback) { -> { p "debug" } } # rubocop:disable Lint/Debugger
let(:callback) { -> { p "debug" } }
let(:strategy) { :replace }
let(:jid) { "bogusjobid" }
let(:item) do
Expand Down
14 changes: 7 additions & 7 deletions spec/sidekiq_unique_jobs/lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

it "creates all expected keys in redis" do
create
expect(keys).to match_array([key.digest, key.locked, key.info, key.changelog, key.digests])
expect(keys).to contain_exactly(key.digest, key.locked, key.info, key.changelog, key.digests)
expect(create.locked_jids).to include(job_id)
end
end
Expand All @@ -54,13 +54,13 @@
subject(:all_jids) { entity.all_jids }

context "when no locks exist" do
it { is_expected.to match_array([]) }
it { is_expected.to eq([]) }
end

context "when locks exists" do
before { simulate_lock(key, job_id) }

it { is_expected.to match_array([job_id]) }
it { is_expected.to contain_exactly(job_id) }
end
end

Expand All @@ -70,7 +70,7 @@
it "creates keys and adds job_id to locked hash" do
expect { lock }.to change { entity.locked_jids }.to([job_id])

expect(keys).to match_array([key.digest, key.locked, key.info, key.changelog, key.digests])
expect(keys).to contain_exactly(key.digest, key.locked, key.info, key.changelog, key.digests)
end
end

Expand All @@ -82,15 +82,15 @@
it "creates keys and adds job_id to locked hash" do
expect { lock }.to change { entity.locked_jids }.to([job_id])
del
expect(keys).not_to match_array([key.digest, key.locked, key.info, key.changelog, key.digests])
expect(keys).not_to contain_exactly(key.digest, key.locked, key.info, key.changelog, key.digests)
end
end

describe "#changelogs" do
subject(:changelogs) { entity.changelogs }

context "when no changelogs exist" do
it { is_expected.to match_array([]) }
it { is_expected.to eq([]) }
end

context "when changelogs exist" do
Expand All @@ -115,7 +115,7 @@
}
end

it { is_expected.to match_array([locked_entry, queued_entry]) }
it { is_expected.to contain_exactly(locked_entry, queued_entry) }
end
end
end
12 changes: 6 additions & 6 deletions spec/sidekiq_unique_jobs/lua/lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
expect(primed.count).to eq(0)

expect(locked.count).to eq(1)
expect(locked.entries).to match_array([job_id_one])
expect(locked.entries).to contain_exactly(job_id_one)
expect(locked[job_id_one].to_f).to be_within(0.5).of(now_f)
end
end
Expand All @@ -176,7 +176,7 @@
expect(primed.count).to eq(0)

expect(locked.count).to eq(1)
expect(locked.entries).to match_array([job_id_one])
expect(locked.entries).to contain_exactly(job_id_one)
expect(locked[job_id_one].to_f).to be_within(0.5).of(now_f)
end
end
Expand All @@ -197,7 +197,7 @@
expect(primed.count).to eq(0)

expect(locked.count).to eq(1)
expect(locked.entries).to match_array([job_id_one])
expect(locked.entries).to contain_exactly(job_id_one)
expect(locked[job_id_one].to_f).to be_within(0.5).of(now_f)
end
end
Expand All @@ -220,7 +220,7 @@
expect(primed.count).to eq(0)

expect(locked.count).to eq(1)
expect(locked.entries).to match_array([job_id_two])
expect(locked.entries).to contain_exactly(job_id_two)
expect(locked[job_id_two].to_f).to be_within(0.5).of(now_f)
end
end
Expand All @@ -247,7 +247,7 @@
expect(primed.count).to eq(0)

expect(locked.count).to eq(2)
expect(locked.entries).to match_array([job_id_two, job_id_one])
expect(locked.entries).to contain_exactly(job_id_two, job_id_one)
expect(locked[job_id_two].to_f).to be_within(0.5).of(now_f)
expect(locked[job_id_one].to_f).to be_within(0.5).of(now_f)
end
Expand All @@ -272,7 +272,7 @@
expect(primed.count).to eq(0)

expect(locked.count).to eq(1)
expect(locked.entries).to match_array([job_id_one])
expect(locked.entries).to contain_exactly(job_id_one)
expect(locked[job_id_one].to_f).to be_within(0.5).of(now_f)
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/sidekiq_unique_jobs/lua/queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
expect(get(key.digest)).to eq(job_id_two)
expect(pttl(key.digest)).to eq(-1) # key exists without pttl
expect(llen(key.queued)).to eq(1)
expect(lrange(key.queued, 0, -1)).to match_array([job_id_two])
expect(lrange(key.queued, 0, -1)).to contain_exactly(job_id_two)
expect(rpop(key.queued)).to eq(job_id_two)
expect(exists(key.primed)).to be(false)
expect(exists(key.locked)).to be(false)
Expand All @@ -84,7 +84,7 @@
expect(get(key.digest)).to eq(job_id_one)
expect(pttl(key.digest)).to eq(-1) # key exists without pttl
expect(llen(key.queued)).to eq(2)
expect(lrange(key.queued, 0, -1)).to match_array([job_id_two, job_id_one])
expect(lrange(key.queued, 0, -1)).to contain_exactly(job_id_two, job_id_one)
expect(rpop(key.queued)).to eq(job_id_two)
expect(exists(key.primed)).to be(false)
expect(exists(key.locked)).to be(false)
Expand All @@ -104,7 +104,7 @@
expect(get(key.digest)).to eq(job_id_one)
expect(pttl(key.digest)).to eq(-1) # key exists without pttl
expect(llen(key.queued)).to eq(1)
expect(lrange(key.queued, 0, -1)).to match_array([job_id_one])
expect(lrange(key.queued, 0, -1)).to contain_exactly(job_id_one)
expect(rpop(key.queued)).to eq(job_id_one)
expect(exists(key.primed)).to be(false)
expect(exists(key.locked)).to be(false)
Expand Down Expand Up @@ -141,7 +141,7 @@
expect(queue).to eq(job_id_one)
expect(get(key.digest)).to eq(job_id_one)
expect(llen(key.queued)).to eq(1) # There should be no keys available to be locked
expect(lrange(key.queued, 0, -1)).to match_array([job_id_one])
expect(lrange(key.queued, 0, -1)).to contain_exactly(job_id_one)
expect(llen(key.primed)).to eq(0)
expect(exists(key.locked)).to be(true)
expect(hexists(key.locked, job_id_two)).to be(1)
Expand Down
16 changes: 8 additions & 8 deletions spec/sidekiq_unique_jobs/lua/reap_orphans_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
context "without scheduled job" do
it "keeps the digest" do
expect { reap_orphans }.to change { digests.count }.by(-1)
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end
end

Expand All @@ -70,7 +70,7 @@

it "keeps the digest" do
expect { reap_orphans }.not_to change { digests.count }.from(1)
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
end
end
end
Expand All @@ -81,7 +81,7 @@
context "without job in retry" do
it "keeps the digest" do
expect { reap_orphans }.to change { digests.count }.by(-1)
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end
end

Expand All @@ -90,7 +90,7 @@

it "keeps the digest" do
expect { reap_orphans }.not_to change { digests.count }.from(1)
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
end
end
end
Expand All @@ -99,7 +99,7 @@
context "without enqueued job" do
it "keeps the digest" do
expect { reap_orphans }.to change { digests.count }.by(-1)
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end
end

Expand All @@ -108,7 +108,7 @@

it "keeps the digest" do
expect { reap_orphans }.not_to change { digests.count }.from(1)
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
end
end
end
Expand All @@ -117,7 +117,7 @@
context "without job" do
it "keeps the digest" do
expect { reap_orphans }.to change { digests.count }.by(-1)
expect(unique_keys).to match_array([])
expect(unique_keys).to eq([])
end
end

Expand All @@ -143,7 +143,7 @@

it "keeps the digest" do
expect { reap_orphans }.not_to change { digests.count }.from(1)
expect(unique_keys).not_to match_array([])
expect(unique_keys).not_to eq([])
end
end
end
Expand Down
Loading

0 comments on commit 7026868

Please sign in to comment.