-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [eas-cli] Stop app config error repeating If app config error is thrown it is re-thrown with modified message instead of printing it to the as a "cryptic error" and repeating with 0% chances of success (since the config is incorrect) See: https://linear.app/expo/issue/ENG-7536/make-app-config-error-on-credentials-command-not-repeat-indefinitely * [eas-cli] Create custom error Replaced generic error with specific message with a custom error class, which allows for not relying on a message to be exactly as expected See: https://linear.app/expo/issue/ENG-7536/make-app-config-error-on-credentials-command-not-repeat-indefinitely * update CHANGELOG.md * [eas-cli] Remove blank line Removed blank line from changelog See: https://linear.app/expo/issue/ENG-7536/make-app-config-error-on-credentials-command-not-repeat-indefinitely
- Loading branch information
1 parent
324dce8
commit 9ff47af
Showing
5 changed files
with
86 additions
and
1 deletion.
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
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
69 changes: 69 additions & 0 deletions
69
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,69 @@ | ||
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 { AndroidPackageNotDefinedError } from '../../errors'; | ||
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 AndroidPackageNotDefinedError( | ||
'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 AndroidPackageNotDefinedError( | ||
'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); | ||
}); | ||
}); | ||
}); |