-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[supply] add new SUPPLY_UPLOAD_MAX_RETRIES env var to attempt to solve failed Google API calls #21518
Merged
Merged
[supply] add new SUPPLY_UPLOAD_MAX_RETRIES env var to attempt to solve failed Google API calls #21518
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that I got bitten by in the past is that when you stub
UI.user_error!
withexpect
orallow
, that means that the original method won't be called… which means that it won'traise
.As a result, the caller of
call_google_api
, in your caseclient.upload_image
, won't be interrupted by theFastlane::Error
raised byuser_error!
in the context of running tests, while it will in the real world.Depending on the implementation of
client.upload_image(…)
, that could have side effects if that implementation counts on the fact thatcall_google_api
can raise to stop early and not run the rest of the code of that method on error, as that would mean that the fact that we stubbeduser_error!
would make the method under test behave differently in test environment vs in reality.I think the easiest way to solve this would be to replace your
expect(UI).to receive(:user_error!)
with wrapping your call toclient.upload_image
withinexpect { … }.to raise_error(Fastlane::Error, "Google Api Error: Invalid request – Ensure project settings are enabled."
. That way you'd letuser_error!
raise and interrupt the code ofupload_image
mid-air even in the context of testing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AliSoftware That expect on
UI.user_error!
was already there 🤷 But... would be adding.and_call_original
work? 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that would, except that I think
rubocop
might suggest you to only call.and_call_original
onallow(…)
, not onexpect(…)
So you could
allow(UI).to receive(:user_error!).with(…).and_call_original
… but if you do that and even if you wanted to still keep theexpect(UI).to receive(:user_error!).once
to assert on it only being called once and not more, you'll still need to wrap yourclient.upload_image
withinexpect { … }.to raise_error(…)
to avoid the test from crashing on the raised error and instead catch (and assert) it.So at this point since you'll still need the
expect { … } .to raise_error
, I'm not sure thatand_call_original
adds much value, instead of not stubbingUI.user_error!
at all?