Skip to content

Commit 9a5c8a4

Browse files
authored
uncommented test (#8)
1 parent 7c77ee3 commit 9a5c8a4

File tree

1 file changed

+44
-43
lines changed

1 file changed

+44
-43
lines changed

integ-test/test-construct.test.ts

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,74 @@
1-
import { AmplifyExportBackend, CategoryStackMapping } from '../src';
1+
import { AmplifyExportedBackend, CategoryStackMapping } from '../src';
22
import * as path from 'path';
33
import * as cdk from '@aws-cdk/core';
44
import * as fs from 'fs-extra';
55
import { expect as cdkExpect, countResources, haveResource, } from '@aws-cdk/assert';
66
import { ResourceTypeConstants } from './resource-type-string-generator';
7+
78
// eslint-disable-next-line import/no-unresolved
8-
//import { exportBackend, /*deleteProject, deleteProjectDir,*/ initProjectWithAccessKey, addAuthWithMaxOptions, addConvert, addDEVHosting, addInterpret, addRestApi, addS3StorageWithIdpAuth, addSMSNotification, addSampleInteraction, addFunction } from './amplify-e2e-core/lib';
9+
import { exportBackend, deleteProject, deleteProjectDir, initProjectWithAccessKey, addAuthWithMaxOptions, addConvert, addDEVHosting, addInterpret, addRestApi, addS3StorageWithIdpAuth, addSMSNotification, addSampleInteraction, addFunction } from './amplify-e2e-core/lib';
910

1011
jest.setTimeout(500000);
1112

1213
describe('test construct', () => {
1314
let projRoot: string;
14-
//let exportProj: string;
15-
let exportedBackendConstruct: AmplifyExportBackend;
15+
let exportProj: string;
16+
let exportedBackendConstruct: AmplifyExportedBackend;
1617
const projectName = 'exportTestProject';
1718
let categoryStackMapping: CategoryStackMapping[];
1819

1920
beforeAll(async () => {
2021
projRoot = path.join(__dirname, 'exportTestProject');
2122
categoryStackMapping = JSON.parse(fs.readFileSync(path.join(`amplify-export-${projectName}`, 'category-stack-mapping.json'), { encoding: 'utf-8' })) as CategoryStackMapping[];
2223

23-
//exportProj = path.join(__dirname);
24-
// expect(process.env.AWS_ACCESS_KEY_ID).toBeDefined();
25-
// expect(process.env.AMPLIFY_PATH).toBeDefined();
26-
// expect(process.env.AWS_SECRET_ACCESS_KEY).toBeDefined();
27-
// expect(process.env.AWS_SESSION_TOKEN).toBeDefined();
24+
exportProj = path.join(__dirname);
25+
expect(process.env.AWS_ACCESS_KEY_ID).toBeDefined();
26+
expect(process.env.AMPLIFY_PATH).toBeDefined();
27+
expect(process.env.AWS_SECRET_ACCESS_KEY).toBeDefined();
28+
expect(process.env.AWS_SESSION_TOKEN).toBeDefined();
2829

2930
fs.ensureDirSync(projRoot);
30-
// await initProjectWithAccessKey(projRoot, {
31-
// accessKeyId: process.env.AWS_ACCESS_KEY_ID || '',
32-
// secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || '',
33-
// region: 'us-east-2',
34-
// });
35-
// await addAuthWithMaxOptions(projRoot, {});
36-
// await addSampleInteraction(projRoot, {});
37-
// await addFunction(projRoot, { functionTemplate: 'Hello World' }, 'nodejs');
38-
// //await addApiWithoutSchema(projRoot);
39-
40-
// await addSMSNotification(projRoot, { resourceName: 'export-test' });
41-
// await addRestApi(projRoot, {
42-
// existingLambda: false,
43-
// isCrud: false,
44-
// isFirstRestApi: false,
45-
// });
46-
// await addDEVHosting(projRoot);
47-
// await addS3StorageWithIdpAuth(projRoot);
48-
// await addConvert(projRoot, {});
49-
// await addInterpret(projRoot, {});
50-
// fs.ensureDirSync(exportProj);
51-
// await exportBackend(projRoot, { exportPath: exportProj });
52-
// fs.moveSync(path.join('integ-test', `amplify-export-${projectName}`), path.join(`amplify-export-${projectName}`));
31+
await initProjectWithAccessKey(projRoot, {
32+
accessKeyId: process.env.AWS_ACCESS_KEY_ID || '',
33+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || '',
34+
region: 'us-east-2',
35+
});
36+
await addAuthWithMaxOptions(projRoot, {});
37+
await addSampleInteraction(projRoot, {});
38+
await addFunction(projRoot, { functionTemplate: 'Hello World' }, 'nodejs');
39+
//await addApiWithoutSchema(projRoot);
40+
41+
await addSMSNotification(projRoot, { resourceName: 'export-test' });
42+
await addRestApi(projRoot, {
43+
existingLambda: false,
44+
isCrud: false,
45+
isFirstRestApi: false,
46+
});
47+
await addDEVHosting(projRoot);
48+
await addS3StorageWithIdpAuth(projRoot);
49+
await addConvert(projRoot, {});
50+
await addInterpret(projRoot, {});
51+
fs.ensureDirSync(exportProj);
52+
await exportBackend(projRoot, { exportPath: exportProj });
53+
fs.moveSync(path.join('integ-test', `amplify-export-${projectName}`), path.join(`amplify-export-${projectName}`));
5354
const app = new cdk.App();
54-
exportedBackendConstruct = new AmplifyExportBackend(app, 'amplify-exported-backend', {
55+
exportedBackendConstruct = new AmplifyExportedBackend(app, 'amplify-exported-backend', {
5556
path: `amplify-export-${projectName}`,
5657
stage: 'dev',
5758
});
5859
});
5960

6061
afterAll(async () => {
61-
// await deleteProject(projRoot, {
62-
// region: 'us-east-2',
63-
// credentials: {
64-
// accessKeyId: process.env.AWS_ACCESS_KEY_ID,
65-
// secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
66-
// sessionToken: process.env.AWS_SESSION_TOKEN
67-
// }
68-
// });
69-
// deleteProjectDir(projRoot);
70-
// deleteProjectDir(`amplify-export-${projectName}`);
62+
await deleteProject(projRoot, {
63+
region: 'us-east-2',
64+
credentials: {
65+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
66+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
67+
sessionToken: process.env.AWS_SESSION_TOKEN
68+
}
69+
});
70+
deleteProjectDir(projRoot);
71+
deleteProjectDir(`amplify-export-${projectName}`);
7172
});
7273

7374
test('exportedBackendConstruct is defined', () => {

0 commit comments

Comments
 (0)