-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: flag to allow destructive schema changes (#8273)
* chore: dumping table changes * chore: drop table POC * feat: plumb destructive-updates flag * feat: plumb rebuild * chore: fix rebuild prompts * test: adding unit and e2e tests * feat: sweet jesus it works * fix: iterative push lambda with updates * chore: organize code better * test: add unit and e2e tests * chore: fit and finish * chore: didn't save all the files * test: fix some tests and add a couple more * chore: address PR comments * test: fix e2e failures * chore: fix prompts dep version * test: exclude new api tests from windows * test: update test schema * chore: address PR comments * fix: messed up merge * test: fix e2e failures
- Loading branch information
1 parent
f078323
commit 18de856
Showing
39 changed files
with
1,445 additions
and
226 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,18 +1,9 @@ | ||
{ | ||
"name": "api", | ||
"type": "category", | ||
"commands": [ | ||
"add-graphql-datasource", | ||
"add", | ||
"console", | ||
"gql-compile", | ||
"push", | ||
"remove", | ||
"update", | ||
"help" | ||
], | ||
"commandAliases":{ | ||
"configure": "update" | ||
}, | ||
"eventHandlers": [] | ||
} | ||
"name": "api", | ||
"type": "category", | ||
"commands": ["add-graphql-datasource", "add", "console", "gql-compile", "push", "rebuild", "remove", "update", "help"], | ||
"commandAliases": { | ||
"configure": "update" | ||
}, | ||
"eventHandlers": [] | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/amplify-category-api/src/__tests__/commands/api/rebuild.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,64 @@ | ||
import { $TSContext, FeatureFlags, stateManager } from 'amplify-cli-core'; | ||
import { printer, prompter } from 'amplify-prompts'; | ||
import { mocked } from 'ts-jest/utils'; | ||
import { run } from '../../../commands/api/rebuild'; | ||
|
||
jest.mock('amplify-cli-core'); | ||
jest.mock('amplify-prompts'); | ||
|
||
const FeatureFlags_mock = mocked(FeatureFlags); | ||
const stateManager_mock = mocked(stateManager); | ||
const printer_mock = mocked(printer); | ||
const prompter_mock = mocked(prompter); | ||
|
||
FeatureFlags_mock.getBoolean.mockReturnValue(true); | ||
|
||
beforeEach(jest.clearAllMocks); | ||
|
||
const pushResourcesMock = jest.fn(); | ||
|
||
const context_stub = { | ||
amplify: { | ||
constructExeInfo: jest.fn(), | ||
pushResources: pushResourcesMock, | ||
}, | ||
parameters: { | ||
first: 'resourceName', | ||
}, | ||
} as unknown as $TSContext; | ||
|
||
it('prints error if iterative updates not enabled', async () => { | ||
FeatureFlags_mock.getBoolean.mockReturnValueOnce(false); | ||
|
||
await run(context_stub); | ||
|
||
expect(printer_mock.error.mock.calls.length).toBe(1); | ||
expect(pushResourcesMock.mock.calls.length).toBe(0); | ||
}); | ||
|
||
it('exits early if no api in project', async () => { | ||
stateManager_mock.getMeta.mockReturnValueOnce({ | ||
api: {}, | ||
}); | ||
|
||
await run(context_stub); | ||
|
||
expect(printer_mock.info.mock.calls.length).toBe(1); | ||
expect(pushResourcesMock.mock.calls.length).toBe(0); | ||
}); | ||
|
||
it('asks for strong confirmation before continuing', async () => { | ||
stateManager_mock.getMeta.mockReturnValueOnce({ | ||
api: { | ||
testapiname: { | ||
service: 'AppSync', | ||
}, | ||
}, | ||
}); | ||
|
||
await run(context_stub); | ||
|
||
expect(prompter_mock.input.mock.calls.length).toBe(1); | ||
expect(pushResourcesMock.mock.calls.length).toBe(1); | ||
expect(pushResourcesMock.mock.calls[0][4]).toBe(true); // rebuild flag is set | ||
}); |
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
Oops, something went wrong.