forked from aws-amplify/amplify-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reclassify BucketNotExists error during init-env (aws-amplify#12399
- Loading branch information
1 parent
4749e46
commit 7cd5d27
Showing
2 changed files
with
52 additions
and
19 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/amplify-provider-awscloudformation/src/__tests__/initialize-env.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,34 @@ | ||
import { downloadZip } from '../zip-util'; | ||
import { run } from '../initialize-env'; | ||
import { $TSContext, AmplifyException } from 'amplify-cli-core'; | ||
|
||
jest.mock('../aws-utils/aws-s3'); | ||
jest.mock('../zip-util'); | ||
|
||
const downloadZipMock = downloadZip as jest.MockedFunction<typeof downloadZip>; | ||
|
||
describe('initialize environment', () => { | ||
const contextStub = { | ||
amplify: { | ||
pathManager: { | ||
getAmplifyDirPath: jest.fn().mockReturnValue('some/path'), | ||
getCurrentCloudBackendDirPath: jest.fn(), | ||
getBackendDirPath: jest.fn(), | ||
}, | ||
}, | ||
} as unknown as $TSContext; | ||
it('throws AmplifyError if the deployment bucket does not exist', async () => { | ||
downloadZipMock.mockRejectedValueOnce({ code: 'NoSuchBucket' }); | ||
const actual = await expect(run(contextStub, {})).rejects; | ||
actual.toBeInstanceOf(AmplifyException); | ||
actual.toMatchInlineSnapshot( | ||
`[EnvironmentNotInitializedError: Could not find a deployment bucket for the specified backend environment. This environment may have been deleted.]`, | ||
); | ||
}); | ||
|
||
it('throws underlying error if the deployment bucket exists but fetching current-cloud-backend zip fails for some other reason', async () => { | ||
const errStub = { code: 'SomethingElse' }; | ||
downloadZipMock.mockRejectedValueOnce(errStub); | ||
await expect(run(contextStub, {})).rejects.toEqual(errStub); | ||
}); | ||
}); |
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