-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e tests and change location of raisePrePushEvent firing o…
…n init
- Loading branch information
1 parent
adf9d34
commit 692362b
Showing
11 changed files
with
146 additions
and
21 deletions.
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
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
13 changes: 8 additions & 5 deletions
13
packages/amplify-cli/src/utils/verify-expected-env-params.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
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
83 changes: 83 additions & 0 deletions
83
packages/amplify-e2e-tests/src/__tests__/init-force-push.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,83 @@ | ||
import { | ||
addFunction, | ||
amplifyPushAuth, | ||
createNewProjectDir, | ||
deleteProject, | ||
deleteProjectDir, | ||
deleteSSMParameter, | ||
generateRandomShortId, | ||
getAmplifyInitConfig, | ||
getProjectConfig, | ||
getProjectMeta, | ||
getTeamProviderInfo, | ||
initJSProjectWithProfile, | ||
nonInteractiveInitWithForcePushAttach, | ||
setTeamProviderInfo, | ||
} from '@aws-amplify/amplify-e2e-core'; | ||
|
||
describe('init --forcePush', () => { | ||
const envName = 'testtest'; | ||
let projRoot: string; | ||
let funcName: string; | ||
beforeEach(async () => { | ||
projRoot = await createNewProjectDir('original'); | ||
await initJSProjectWithProfile(projRoot, { envName, disableAmplifyAppCreation: false }); | ||
funcName = `testfunction${generateRandomShortId()}`; | ||
await addFunction( | ||
projRoot, | ||
{ | ||
functionTemplate: 'Hello World', | ||
name: funcName, | ||
environmentVariables: { | ||
key: 'FOO_BAR', | ||
value: 'fooBar', | ||
}, | ||
}, | ||
'nodejs', | ||
); | ||
await amplifyPushAuth(projRoot); | ||
}); | ||
|
||
afterEach(async () => { | ||
await deleteProject(projRoot); | ||
deleteProjectDir(projRoot); | ||
}); | ||
it('fails fast on missing env parameters', async () => { | ||
const { projectName } = getProjectConfig(projRoot); | ||
|
||
// remove env param from TPI | ||
const tpi = getTeamProviderInfo(projRoot); | ||
delete tpi?.[envName]?.categories?.function?.[funcName]?.fooBar; | ||
setTeamProviderInfo(projRoot, tpi); | ||
|
||
// remote env param from ParameterStore | ||
const meta = getProjectMeta(projRoot); | ||
const { AmplifyAppId: appId, Region: region } = meta?.providers?.awscloudformation; | ||
await deleteSSMParameter(region, appId, 'testtest', 'function', funcName, 'fooBar'); | ||
|
||
// init --forcePush should fail due to missing param | ||
const result = await nonInteractiveInitWithForcePushAttach( | ||
projRoot, | ||
getAmplifyInitConfig(projectName, 'newenv'), | ||
undefined, | ||
true, | ||
undefined, | ||
false, // don't reject on failure | ||
); | ||
expect(result.exitCode).toBe(1); | ||
}); | ||
|
||
it('restores missing param from ParameterStore', async () => { | ||
const { projectName } = getProjectConfig(projRoot); | ||
|
||
// remove env param from TPI | ||
const tpi = getTeamProviderInfo(projRoot); | ||
delete tpi?.[envName]?.categories?.function?.[funcName]?.fooBar; | ||
setTeamProviderInfo(projRoot, tpi); | ||
|
||
await nonInteractiveInitWithForcePushAttach(projRoot, getAmplifyInitConfig(projectName, envName), undefined, true); | ||
|
||
const tpiAfter = getTeamProviderInfo(projRoot); | ||
expect(tpiAfter?.[envName]?.categories?.function?.[funcName]?.fooBar).toBe('fooBar'); | ||
}); | ||
}); |