-
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.
fix(api): add null placeholder for nested stack during api rebuild (#…
…11460) * fix(api): add null placeholder for nested stack during api rebuild
- Loading branch information
1 parent
1e7aee8
commit 23168f0
Showing
7 changed files
with
192 additions
and
21 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
18 changes: 18 additions & 0 deletions
18
packages/amplify-e2e-tests/schemas/relational_models_v2.graphql
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,18 @@ | ||
input AMPLIFY { | ||
globalAuthRule: AuthRule = { allow: public } | ||
} | ||
type Todo @model { | ||
id: ID! | ||
name: String | ||
description: String | ||
tasks: [Task] @hasMany | ||
assignee: Worker @hasOne | ||
} | ||
type Task @model { | ||
id: ID! | ||
todo: Todo @belongsTo | ||
} | ||
type Worker @model { | ||
id: ID! | ||
todo: Todo @belongsTo | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/amplify-e2e-tests/schemas/searchable_model_v2.graphql
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,8 @@ | ||
input AMPLIFY { | ||
globalAuthRule: AuthRule = { allow: public } | ||
} | ||
type Todo @model @searchable { | ||
id: ID! | ||
name: String | ||
description: String | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
createNewProjectDir, | ||
initJSProjectWithProfile, | ||
addApiWithoutSchema, | ||
amplifyPush, | ||
deleteProjectDir, | ||
rebuildApi, | ||
getProjectMeta, | ||
updateApiSchema, | ||
deleteProject, | ||
} from '@aws-amplify/amplify-e2e-core'; | ||
import { testTableAfterRebuildApi, testTableBeforeRebuildApi } from '../rebuild-test-helpers'; | ||
|
||
const projName = 'apitest'; | ||
|
||
let projRoot; | ||
beforeEach(async () => { | ||
projRoot = await createNewProjectDir(projName); | ||
}); | ||
afterEach(async () => { | ||
await deleteProject(projRoot, undefined, false, 1000 * 60 * 30); | ||
deleteProjectDir(projRoot); | ||
}); | ||
|
||
describe('amplify rebuild api', () => { | ||
it('recreates tables for searchable models', async () => { | ||
await initJSProjectWithProfile(projRoot, { name: projName }); | ||
await addApiWithoutSchema(projRoot, { transformerVersion: 2 }); | ||
await updateApiSchema(projRoot, projName, 'searchable_model_v2.graphql'); | ||
await amplifyPush(projRoot); | ||
const projMeta = getProjectMeta(projRoot); | ||
const apiId = projMeta?.api?.[projName]?.output?.GraphQLAPIIdOutput; | ||
const region = projMeta?.providers?.awscloudformation?.Region; | ||
expect(apiId).toBeDefined(); | ||
expect(region).toBeDefined(); | ||
await testTableBeforeRebuildApi(apiId, region, 'Todo'); | ||
await rebuildApi(projRoot, projName); | ||
await testTableAfterRebuildApi(apiId, region, 'Todo'); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/amplify-e2e-tests/src/rebuild-test-helpers/index.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,14 @@ | ||
import { putItemInTable, scanTable } from '@aws-amplify/amplify-e2e-core'; | ||
|
||
export const testTableBeforeRebuildApi = async (apiId: string, region: string, modelName: string) => { | ||
const tableName = `${modelName}-${apiId}-integtest`; | ||
await putItemInTable(tableName, region, { id: 'this is a test value' }); | ||
const scanResultBefore = await scanTable(tableName, region); | ||
expect(scanResultBefore.Items.length).toBe(1); | ||
}; | ||
|
||
export const testTableAfterRebuildApi = async (apiId: string, region: string, modelName: string) => { | ||
const tableName = `${modelName}-${apiId}-integtest`; | ||
const scanResultAfter = await scanTable(tableName, region); | ||
expect(scanResultAfter.Items.length).toBe(0); | ||
}; |
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