Skip to content

Commit

Permalink
test: fix delete test to fail as expected (#6474)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhockett authored Jan 25, 2021
1 parent 4653062 commit 5e4648c
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions packages/amplify-e2e-tests/src/__tests__/delete.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import { S3, Amplify } from 'aws-sdk';
import { initJSProjectWithProfile, initIosProjectWithProfile, initAndroidProjectWithProfile, deleteProject } from 'amplify-e2e-core';
import {
addPinpointAnalytics,
addApiWithoutSchema,
addAuthWithDefault,
addS3,
amplifyDelete,
amplifyPushWithoutCodegen,
bucketNotExists,
createNewProjectDir,
deleteProject,
deleteProjectDir,
getProjectMeta,
getS3StorageBucketName,
getAWSConfigIOSPath,
deleteS3Bucket,
initAndroidProjectWithProfile,
initIosProjectWithProfile,
initJSProjectWithProfile,
initProjectForPinpoint,
getAmplifyConfigAndroidPath,
getAmplifyConfigIOSPath,
getAWSConfigAndroidPath,
getAmplifyConfigAndroidPath,
bucketNotExists,
deleteS3Bucket,
getAWSConfigIOSPath,
getProjectMeta,
getS3StorageBucketName,
pinpointAppExist,
pushToCloud,
} from 'amplify-e2e-core';
import { addEnvironment, checkoutEnvironment, removeEnvironment } from '../environment/env';
import { addApiWithoutSchema } from 'amplify-e2e-core';
import { addCodegen } from '../codegen/add';
import { addS3 } from 'amplify-e2e-core';
import { amplifyPushWithoutCodegen } from 'amplify-e2e-core';
import { addAuthWithDefault } from 'amplify-e2e-core';
import * as fs from 'fs-extra';
import { initProjectForPinpoint, addPinpointAnalytics, pushToCloud, pinpointAppExist, amplifyDelete } from 'amplify-e2e-core';
import { getAWSExportsPath } from '../aws-exports/awsExports';
import _ from 'lodash';

Expand Down Expand Up @@ -68,10 +75,10 @@ describe('amplify delete', () => {
const amplifyMeta = getProjectMeta(projRoot);
const meta = amplifyMeta.providers.awscloudformation;
const deploymentBucketName1 = meta.DeploymentBucketName;
await expect(await bucketExists(deploymentBucketName1)).toBe(true);
expect(await bucketExists(deploymentBucketName1)).toBe(true);
await checkoutEnvironment(projRoot, { envName: 'testdev' });
await removeEnvironment(projRoot, { envName: 'testprod' });
await expect(await bucketNotExists(deploymentBucketName1)).toBe(true);
expect(await bucketNotExists(deploymentBucketName1)).toBe(true);
await deleteProject(projRoot);
});

Expand All @@ -82,16 +89,17 @@ describe('amplify delete', () => {
await amplifyPushWithoutCodegen(projRoot);
const bucketName = getS3StorageBucketName(projRoot);
await putFiles(bucketName);
expect(await bucketExists(bucketName)).toBeTruthy();
expect(await bucketExists(bucketName)).toBe(true);
await deleteProject(projRoot);
expect(await bucketNotExists(bucketName)).toBeTruthy();
expect(await bucketNotExists(bucketName)).toBe(true);
});

it('should try deleting unavailable bucket but not fail', async () => {
await initJSProjectWithProfile(projRoot, {});
const amplifyMeta = getProjectMeta(projRoot);
const meta = amplifyMeta.providers.awscloudformation;
const bucketName = meta.DeploymentBucketName;
expect(await bucketExists(bucketName)).toBeTruthy();
expect(await bucketExists(bucketName)).toBe(true);
await deleteS3Bucket(bucketName);
await deleteProject(projRoot);
});
Expand Down

0 comments on commit 5e4648c

Please sign in to comment.