From d57fed8d9a473d104b8df0436cabdb82d6fcf88e Mon Sep 17 00:00:00 2001 From: AmmarKarachi Date: Wed, 3 Nov 2021 14:04:09 -0700 Subject: [PATCH] uncommented test --- integ-test/test-construct.test.ts | 87 ++++++++++++++++--------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/integ-test/test-construct.test.ts b/integ-test/test-construct.test.ts index 13e8e11..d650274 100644 --- a/integ-test/test-construct.test.ts +++ b/integ-test/test-construct.test.ts @@ -1,18 +1,19 @@ -import { AmplifyExportBackend, CategoryStackMapping } from '../src'; +import { AmplifyExportedBackend, CategoryStackMapping } from '../src'; import * as path from 'path'; import * as cdk from '@aws-cdk/core'; import * as fs from 'fs-extra'; import { expect as cdkExpect, countResources, haveResource, } from '@aws-cdk/assert'; import { ResourceTypeConstants } from './resource-type-string-generator'; + // eslint-disable-next-line import/no-unresolved -//import { exportBackend, /*deleteProject, deleteProjectDir,*/ initProjectWithAccessKey, addAuthWithMaxOptions, addConvert, addDEVHosting, addInterpret, addRestApi, addS3StorageWithIdpAuth, addSMSNotification, addSampleInteraction, addFunction } from './amplify-e2e-core/lib'; +import { exportBackend, deleteProject, deleteProjectDir, initProjectWithAccessKey, addAuthWithMaxOptions, addConvert, addDEVHosting, addInterpret, addRestApi, addS3StorageWithIdpAuth, addSMSNotification, addSampleInteraction, addFunction } from './amplify-e2e-core/lib'; jest.setTimeout(500000); describe('test construct', () => { let projRoot: string; - //let exportProj: string; - let exportedBackendConstruct: AmplifyExportBackend; + let exportProj: string; + let exportedBackendConstruct: AmplifyExportedBackend; const projectName = 'exportTestProject'; let categoryStackMapping: CategoryStackMapping[]; @@ -20,54 +21,54 @@ describe('test construct', () => { projRoot = path.join(__dirname, 'exportTestProject'); categoryStackMapping = JSON.parse(fs.readFileSync(path.join(`amplify-export-${projectName}`, 'category-stack-mapping.json'), { encoding: 'utf-8' })) as CategoryStackMapping[]; - //exportProj = path.join(__dirname); - // expect(process.env.AWS_ACCESS_KEY_ID).toBeDefined(); - // expect(process.env.AMPLIFY_PATH).toBeDefined(); - // expect(process.env.AWS_SECRET_ACCESS_KEY).toBeDefined(); - // expect(process.env.AWS_SESSION_TOKEN).toBeDefined(); + exportProj = path.join(__dirname); + expect(process.env.AWS_ACCESS_KEY_ID).toBeDefined(); + expect(process.env.AMPLIFY_PATH).toBeDefined(); + expect(process.env.AWS_SECRET_ACCESS_KEY).toBeDefined(); + expect(process.env.AWS_SESSION_TOKEN).toBeDefined(); fs.ensureDirSync(projRoot); - // await initProjectWithAccessKey(projRoot, { - // accessKeyId: process.env.AWS_ACCESS_KEY_ID || '', - // secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || '', - // region: 'us-east-2', - // }); - // await addAuthWithMaxOptions(projRoot, {}); - // await addSampleInteraction(projRoot, {}); - // await addFunction(projRoot, { functionTemplate: 'Hello World' }, 'nodejs'); - // //await addApiWithoutSchema(projRoot); - - // await addSMSNotification(projRoot, { resourceName: 'export-test' }); - // await addRestApi(projRoot, { - // existingLambda: false, - // isCrud: false, - // isFirstRestApi: false, - // }); - // await addDEVHosting(projRoot); - // await addS3StorageWithIdpAuth(projRoot); - // await addConvert(projRoot, {}); - // await addInterpret(projRoot, {}); - // fs.ensureDirSync(exportProj); - // await exportBackend(projRoot, { exportPath: exportProj }); - // fs.moveSync(path.join('integ-test', `amplify-export-${projectName}`), path.join(`amplify-export-${projectName}`)); + await initProjectWithAccessKey(projRoot, { + accessKeyId: process.env.AWS_ACCESS_KEY_ID || '', + secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || '', + region: 'us-east-2', + }); + await addAuthWithMaxOptions(projRoot, {}); + await addSampleInteraction(projRoot, {}); + await addFunction(projRoot, { functionTemplate: 'Hello World' }, 'nodejs'); + //await addApiWithoutSchema(projRoot); + + await addSMSNotification(projRoot, { resourceName: 'export-test' }); + await addRestApi(projRoot, { + existingLambda: false, + isCrud: false, + isFirstRestApi: false, + }); + await addDEVHosting(projRoot); + await addS3StorageWithIdpAuth(projRoot); + await addConvert(projRoot, {}); + await addInterpret(projRoot, {}); + fs.ensureDirSync(exportProj); + await exportBackend(projRoot, { exportPath: exportProj }); + fs.moveSync(path.join('integ-test', `amplify-export-${projectName}`), path.join(`amplify-export-${projectName}`)); const app = new cdk.App(); - exportedBackendConstruct = new AmplifyExportBackend(app, 'amplify-exported-backend', { + exportedBackendConstruct = new AmplifyExportedBackend(app, 'amplify-exported-backend', { path: `amplify-export-${projectName}`, stage: 'dev', }); }); afterAll(async () => { - // await deleteProject(projRoot, { - // region: 'us-east-2', - // credentials: { - // accessKeyId: process.env.AWS_ACCESS_KEY_ID, - // secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, - // sessionToken: process.env.AWS_SESSION_TOKEN - // } - // }); - // deleteProjectDir(projRoot); - // deleteProjectDir(`amplify-export-${projectName}`); + await deleteProject(projRoot, { + region: 'us-east-2', + credentials: { + accessKeyId: process.env.AWS_ACCESS_KEY_ID, + secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, + sessionToken: process.env.AWS_SESSION_TOKEN + } + }); + deleteProjectDir(projRoot); + deleteProjectDir(`amplify-export-${projectName}`); }); test('exportedBackendConstruct is defined', () => {