-
Notifications
You must be signed in to change notification settings - Fork 79
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
[eas-cli] [ENG-7536] Stop app config error repeating #2020
Merged
radoslawkrzemien
merged 7 commits into
main
from
@radoslawkrzemien/ENG-7536-make-app-config-error-not-repeat
Aug 30, 2023
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f9ca5d1
[eas-cli] Stop app config error repeating
radoslawkrzemien 79e541e
Merge remote-tracking branch 'origin/main' into @radoslawkrzemien/ENG…
radoslawkrzemien f4e4baa
[eas-cli] Create custom error
radoslawkrzemien 8acc4d1
update CHANGELOG.md
radoslawkrzemien d65a1bc
Merge remote-tracking branch 'origin/main' into @radoslawkrzemien/ENG…
radoslawkrzemien 1f7efd7
Merge remote-tracking branch 'origin/main' into @radoslawkrzemien/ENG…
radoslawkrzemien 4fae2d7
[eas-cli] Remove blank line
radoslawkrzemien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
66 changes: 66 additions & 0 deletions
66
packages/eas-cli/src/credentials/manager/__tests__/ManageAndroid-test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Platform } from '@expo/eas-build-job'; | ||
import { BuildProfile, EasJsonUtils } from '@expo/eas-json'; | ||
|
||
import { Analytics } from '../../../analytics/AnalyticsManager'; | ||
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient'; | ||
import { learnMore } from '../../../log'; | ||
import { getProjectConfigDescription } from '../../../project/projectUtils'; | ||
import { pressAnyKeyToContinueAsync } from '../../../prompts'; | ||
import { Actor } from '../../../user/User'; | ||
import { getAppLookupParamsFromContextAsync } from '../../android/actions/BuildCredentialsUtils'; | ||
import { CredentialsContextProjectInfo } from '../../context'; | ||
import { Action } from '../HelperActions'; | ||
import { ManageAndroid } from '../ManageAndroid'; | ||
|
||
jest.mock('../../android/actions/BuildCredentialsUtils'); | ||
jest.mock('../../../prompts', () => { | ||
return { | ||
...jest.requireActual('../../../prompts'), | ||
pressAnyKeyToContinueAsync: jest.fn(), | ||
}; | ||
}); | ||
jest.mock('../../../project/projectUtils'); | ||
|
||
describe('runAsync', () => { | ||
describe('"android.package" missing in app.json', () => { | ||
const manageAndroid = new ManageAndroid( | ||
{ | ||
projectInfo: {} as CredentialsContextProjectInfo, | ||
actor: {} as Actor, | ||
graphqlClient: {} as ExpoGraphqlClient, | ||
analytics: {} as Analytics, | ||
getDynamicPrivateProjectConfigAsync: jest | ||
.fn() | ||
.mockResolvedValue({ exp: {}, projectId: '' }), | ||
runAsync: jest.fn(), | ||
} as Action, | ||
'' | ||
); | ||
it('does not repeat the error indefinitely and prints useful error', async () => { | ||
jest.spyOn(EasJsonUtils, 'getBuildProfileNamesAsync').mockResolvedValue(['testProfile']); | ||
jest | ||
.spyOn(EasJsonUtils, 'getBuildProfileAsync') | ||
.mockResolvedValue({} as BuildProfile<Platform.ANDROID>); | ||
jest.mocked(getProjectConfigDescription).mockReturnValue('app.json'); | ||
jest.mocked(getAppLookupParamsFromContextAsync).mockImplementation(() => { | ||
throw new Error('Specify "android.package" in app.json and run this command again.'); | ||
}); | ||
const pressAnyKeyToContinueAsyncMock = jest.mocked(pressAnyKeyToContinueAsync); | ||
Array.from(Array(100)).map((_, i) => { | ||
// continue 101 times if error is rethrown indefinitely | ||
pressAnyKeyToContinueAsyncMock.mockResolvedValueOnce(); | ||
}); | ||
pressAnyKeyToContinueAsyncMock.mockImplementationOnce(async () => { | ||
// fail after 102nd time | ||
fail('test should not reach this place - if it does, the error repeats indefinitely'); | ||
}); | ||
const reThrownError = new Error( | ||
'Specify "android.package" in app.json and run this command again.\n' + | ||
`${learnMore( | ||
'https://docs.expo.dev/workflow/configuration/' | ||
)} about configuration with app.json/app.config.js` | ||
); | ||
await expect(manageAndroid.runAsync()).rejects.toThrow(reThrownError); | ||
}); | ||
}); | ||
}); |
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.
Is there any better way to determine if this is this specific error (not relying on a message)? 🤔 Ideally, it would be good to use an error code or sth like this.
What do you think?
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.
Thought about it, I can make a custom error class for that, probably the best option