Skip to content

Commit 25bc1a6

Browse files
committed
Clarify release lookup error handling
1 parent 3171df5 commit 25bc1a6

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ def find_release(repository:, version:)
254254
def release_for_tag(repository:, version:)
255255
client.release_for_tag(repository, version)
256256
rescue Octokit::NotFound
257+
# A 404 only means the fallback did not find a published release.
258+
# Other API errors should be surfaced.
257259
nil
258260
end
259261

spec/github_helper_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,20 @@ def create_release(is_draft:, assets: [], name: nil)
745745
end
746746
end
747747

748+
it 'does not hide unexpected direct release lookup errors' do
749+
allow(client).to receive(:releases).with(test_repo).and_return([])
750+
allow(client).to receive(:release_for_tag).with(test_repo, test_version).and_raise(Octokit::TooManyRequests)
751+
752+
with_tmp_file(named: 'test-app.zip') do |file_path|
753+
expect(client).not_to receive(:release_assets)
754+
expect(client).not_to receive(:upload_asset)
755+
756+
expect do
757+
upload_release_assets(assets: [file_path])
758+
end.to raise_error(Octokit::TooManyRequests)
759+
end
760+
end
761+
748762
it 'uploads one asset to the existing release' do
749763
with_tmp_file(named: 'test-app.zip') do |file_path|
750764
expect(client).to receive(:upload_asset).with(release_url, file_path, { content_type: 'application/octet-stream' })

0 commit comments

Comments
 (0)