Skip to content

Commit

Permalink
fix(web): don't show bogus lock digests (#804)
Browse files Browse the repository at this point in the history
Closes #761
  • Loading branch information
Earlopain committed Aug 16, 2023
1 parent 02639f8 commit cea0c7b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/sidekiq_unique_jobs/digests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def page(cursor: 0, pattern: SCAN_PATTERN, page_size: 100)
[
total_size.to_i,
digests[0].to_i, # next_cursor
digests[1].map { |digest, score| Lock.new(digest, time: score) }, # entries
digests[1].each_slice(2).map { |digest, score| Lock.new(digest, time: score) }, # entries
]
end
end
Expand Down
12 changes: 12 additions & 0 deletions spec/sidekiq_unique_jobs/digests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,16 @@
)
end
end

describe "#page" do
include_context "with a regular job"

it "returns the correct amount of results" do
total_size, _cursor, locks = digests.page(cursor: 0, page_size: 100, pattern: "*")

expect(locks.size).to be(total_size)
expect(locks.size).to be(expected_keys.size)
expect(expected_keys.keys).to match_array(locks.map(&:key).map(&:digest))
end
end
end
2 changes: 1 addition & 1 deletion spec/sidekiq_unique_jobs/web_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def app
get "/locks/#{digest_one}"

expect(last_response).to be_ok
expect(last_response.body).to match("uniquejobs:9e9b5ce5d423d3ea470977004b50ff84")
expect(last_response.body).to match(digest_one)
end

it "can delete digest" do
Expand Down

0 comments on commit cea0c7b

Please sign in to comment.