GitHub’s app delivery API doesn’t have enough filtering options and allows a maximum of 100 items per page. We have a ‘max_page’ limit to avoid endless pagination. As the number of delivered webhook events has increased, we occasionally hit the max_page limit. Instead of raising the ‘max_page’ limit, I prefer to check it more frequently. Increasing the 'max_page' limit extends the time spent on a single run and raises the risk of apoptosis. It makes more sense to check more frequently with less pages rather than less frequently with more pages.
21 lines
798 B
Ruby
21 lines
798 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../model/spec_helper"
|
|
|
|
RSpec.describe Prog::RedeliverGithubFailures do
|
|
subject(:rgf) {
|
|
described_class.new(Strand.new(prog: "RedeliverGithubFailures", stack: [{"last_check_at" => "2023-10-19 22:27:47 +0000"}]))
|
|
}
|
|
|
|
describe "#wait" do
|
|
it "redelivers failed deliveries and naps" do
|
|
expect(Time).to receive(:now).and_return("2023-10-19 23:27:47 +0000").at_least(:once)
|
|
expect(Github).to receive(:redeliver_failed_deliveries).with(Time.parse("2023-10-19 22:27:47 +0000"))
|
|
expect(rgf.strand).to receive(:save_changes)
|
|
expect {
|
|
expect { rgf.wait }.to nap(2 * 60)
|
|
}.to change { rgf.strand.stack.first["last_check_at"] }.from("2023-10-19 22:27:47 +0000").to("2023-10-19 23:27:47 +0000")
|
|
end
|
|
end
|
|
end
|