Skip to content

Commit 57b9ab3

Browse files
committed
address CRs
1 parent 3a8e967 commit 57b9ab3

File tree

3 files changed

+13
-36
lines changed

3 files changed

+13
-36
lines changed

packages/amplify-e2e-core/src/init/deleteProject.ts

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,16 @@ import { getBackendAmplifyMeta } from '../utils';
66
* Runs `amplify delete`
77
*/
88
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9-
export const deleteProject = async (cwd: string, profileConfig?: any, usingLatestCodebase = false): Promise<void> => {
9+
export const deleteProject = async (cwd: string, profileConfig?: any, usingLatestCodebase = false, noOutputTimeout: number = 1000 * 60 * 20): Promise<void> => {
1010
// Read the meta from backend otherwise it could fail on non-pushed, just initialized projects
11-
try {
12-
const { StackName: stackName, Region: region } = getBackendAmplifyMeta(cwd).providers.awscloudformation;
13-
await retry(
14-
() => describeCloudFormationStack(stackName, region, profileConfig),
15-
stack => stack.StackStatus.endsWith('_COMPLETE') || stack.StackStatus.endsWith('_FAILED'),
16-
);
17-
18-
const noOutputTimeout = 1000 * 60 * 20; // 20 minutes;
19-
return spawn(getCLIPath(usingLatestCodebase), ['delete'], { cwd, stripColors: true, noOutputTimeout })
20-
.wait('Are you sure you want to continue?')
21-
.sendYes()
22-
.wait('Project deleted locally.')
23-
.runAsync();
24-
} catch (e) {
25-
console.log('Error on deleting project at:', cwd);
26-
}
27-
};
28-
29-
export const amplifyDeleteWithLongerTimeout = (cwd: string, usingLatestCodebase = false): Promise<void> => new Promise((resolve, reject) => {
30-
const noOutputTimeout = 1000 * 60 * 30; // 30 minutes;
31-
spawn(getCLIPath(usingLatestCodebase), ['delete'], { cwd, stripColors: true, noOutputTimeout })
11+
const { StackName: stackName, Region: region } = getBackendAmplifyMeta(cwd).providers.awscloudformation;
12+
await retry(
13+
() => describeCloudFormationStack(stackName, region, profileConfig),
14+
stack => stack.StackStatus.endsWith('_COMPLETE') || stack.StackStatus.endsWith('_FAILED'),
15+
);
16+
return spawn(getCLIPath(usingLatestCodebase), ['delete'], { cwd, stripColors: true, noOutputTimeout })
3217
.wait('Are you sure you want to continue?')
3318
.sendConfirmYes()
3419
.wait('Project deleted locally.')
35-
.run((err: Error) => {
36-
if (!err) {
37-
resolve();
38-
} else {
39-
reject(err);
40-
}
41-
});
42-
});
20+
.runAsync();
21+
};

packages/amplify-e2e-tests/src/__tests__/api_6a.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const projName = 'apitest';
1616
let projRoot;
1717
beforeEach(async () => {
1818
projRoot = await createNewProjectDir(projName);
19+
await initJSProjectWithProfile(projRoot, { name: projName });
20+
await addApiWithoutSchema(projRoot, { transformerVersion: 2 });
1921
});
2022
afterEach(async () => {
2123
await deleteProject(projRoot);
@@ -24,8 +26,6 @@ afterEach(async () => {
2426

2527
describe('amplify rebuild api', () => {
2628
it('recreates single table', async () => {
27-
await initJSProjectWithProfile(projRoot, { name: projName });
28-
await addApiWithoutSchema(projRoot, { transformerVersion: 2 });
2929
await amplifyPush(projRoot);
3030
const projMeta = getProjectMeta(projRoot);
3131
const apiId = projMeta?.api?.[projName]?.output?.GraphQLAPIIdOutput;
@@ -37,8 +37,6 @@ describe('amplify rebuild api', () => {
3737
await testTableAfterRebuildApi(apiId, region, 'Todo');
3838
});
3939
it('recreates tables for relational models', async () => {
40-
await initJSProjectWithProfile(projRoot, { name: projName });
41-
await addApiWithoutSchema(projRoot, { transformerVersion: 2 });
4240
await updateApiSchema(projRoot, projName, 'relational_models_v2.graphql');
4341
await amplifyPush(projRoot);
4442
const projMeta = getProjectMeta(projRoot);

packages/amplify-e2e-tests/src/__tests__/api_6c.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
rebuildApi,
88
getProjectMeta,
99
updateApiSchema,
10-
amplifyDeleteWithLongerTimeout,
10+
deleteProject
1111
} from '@aws-amplify/amplify-e2e-core';
1212
import { testTableAfterRebuildApi, testTableBeforeRebuildApi } from '../rebuild-test-helpers';
1313

@@ -18,7 +18,7 @@ beforeEach(async () => {
1818
projRoot = await createNewProjectDir(projName);
1919
});
2020
afterEach(async () => {
21-
await amplifyDeleteWithLongerTimeout(projRoot);
21+
await deleteProject(projRoot, undefined, false, 1000 * 60 * 30);
2222
deleteProjectDir(projRoot);
2323
});
2424

0 commit comments

Comments
 (0)