mirror of
https://github.com/Homebrew/brew.git
synced 2026-08-12 22:29:27 +04:00
Address review feedback: - Add GitHub::API.sleep_for_rate_limit and use it in dev-cmd/bump.rb and dev-cmd/contributions.rb. - Add Utils.exponential_backoff_sleep and use it in dev-cmd/bump.rb, retryable_download.rb and github_packages.rb.
17 lines
508 B
Ruby
17 lines
508 B
Ruby
# typed: true
|
|
# frozen_string_literal: true
|
|
|
|
require "utils/github"
|
|
|
|
RSpec.describe GitHub::API do
|
|
describe "::sleep_for_rate_limit" do
|
|
it "sleeps for at least 1 second even if the rate limit has already reset" do
|
|
exception = GitHub::API::RateLimitExceededError.new(
|
|
"API rate limit exceeded", reset: Time.now.to_i - 10, resource: "core", limit: 5000
|
|
)
|
|
expect(described_class).to receive(:sleep).with(1)
|
|
described_class.sleep_for_rate_limit(exception)
|
|
end
|
|
end
|
|
end
|