@@ -24,55 +24,59 @@ describe('CDK amplify table 1', () => {
2424 deleteProjectDir ( projRoot ) ;
2525 } ) ;
2626
27- test ( 'can update multiple GSIs along with other non-GSI updates' , async ( ) => {
28- const templatePath = path . resolve ( path . join ( __dirname , 'backends' , 'amplify-table' , 'simple-todo' ) ) ;
29- const name = await initCDKProject ( projRoot , templatePath ) ;
30- const outputs = await cdkDeploy ( projRoot , '--all' ) ;
31- const { awsAppsyncApiId : apiId , awsAppsyncRegion : region } = outputs [ name ] ;
32- const tableName = `Todo-${ apiId } -NONE` ;
33- const table = await getDDBTable ( tableName , region ) ;
34- expect ( table ) . toBeDefined ( ) ;
35- expect ( table . Table . BillingModeSummary . BillingMode ) . toBe ( 'PAY_PER_REQUEST' ) ;
36- expect ( table . Table . GlobalSecondaryIndexes [ 0 ] . IndexName ) . toBe ( 'byName' ) ;
37- // Important: When SSE is undefined or set to false,
38- // it doesn't mean SSE is disabled, it means that the table is using AWS owned key for SSE.
39- expect ( table . Table . SSEDescription ) . toBeUndefined ( ) ;
40- expect ( table . Table . StreamSpecification . StreamViewType ) . toBe ( 'NEW_AND_OLD_IMAGES' ) ;
27+ test (
28+ 'can update multiple GSIs along with other non-GSI updates' ,
29+ async ( ) => {
30+ const templatePath = path . resolve ( path . join ( __dirname , 'backends' , 'amplify-table' , 'simple-todo' ) ) ;
31+ const name = await initCDKProject ( projRoot , templatePath ) ;
32+ const outputs = await cdkDeploy ( projRoot , '--all' ) ;
33+ const { awsAppsyncApiId : apiId , awsAppsyncRegion : region } = outputs [ name ] ;
34+ const tableName = `Todo-${ apiId } -NONE` ;
35+ const table = await getDDBTable ( tableName , region ) ;
36+ expect ( table ) . toBeDefined ( ) ;
37+ expect ( table . Table . BillingModeSummary . BillingMode ) . toBe ( 'PAY_PER_REQUEST' ) ;
38+ expect ( table . Table . GlobalSecondaryIndexes [ 0 ] . IndexName ) . toBe ( 'byName' ) ;
39+ // Important: When SSE is undefined or set to false,
40+ // it doesn't mean SSE is disabled, it means that the table is using AWS owned key for SSE.
41+ expect ( table . Table . SSEDescription ) . toBeUndefined ( ) ;
42+ expect ( table . Table . StreamSpecification . StreamViewType ) . toBe ( 'NEW_AND_OLD_IMAGES' ) ;
4143
42- // Verify the tags on the table
43- const tableTags = await getDDBTableTags ( table . Table . TableArn , region ) ;
44- expect ( tableTags . Tags ) . toBeDefined ( ) ;
45- expect ( tableTags . Tags . length ) . toBe ( 3 ) ;
46- expect ( tableTags . Tags ) . toEqual (
47- expect . arrayContaining ( [
48- { Key : 'amplify:deployment-type' , Value : 'sandbox-original' } ,
49- { Key : 'amplify:friendly-name' , Value : 'amplifyData-original' } ,
50- { Key : 'created-by' , Value : 'amplify-original' } ,
51- ] ) ,
52- ) ;
44+ // Verify the tags on the table
45+ const tableTags = await getDDBTableTags ( table . Table . TableArn , region ) ;
46+ expect ( tableTags . Tags ) . toBeDefined ( ) ;
47+ expect ( tableTags . Tags . length ) . toBe ( 3 ) ;
48+ expect ( tableTags . Tags ) . toEqual (
49+ expect . arrayContaining ( [
50+ { Key : 'amplify:deployment-type' , Value : 'sandbox-original' } ,
51+ { Key : 'amplify:friendly-name' , Value : 'amplifyData-original' } ,
52+ { Key : 'created-by' , Value : 'amplify-original' } ,
53+ ] ) ,
54+ ) ;
5355
54- const updateTemplatePath = path . resolve ( path . join ( __dirname , 'backends' , 'amplify-table' , 'simple-todo' , 'updateIndex' ) ) ;
55- updateCDKAppWithTemplate ( projRoot , updateTemplatePath ) ;
56- await cdkDeploy ( projRoot , '--all' , { timeoutMs : DURATION_30_MINUTES } ) ;
57- const updatedTable = await getDDBTable ( tableName , region ) ;
58- expect ( updatedTable ) . toBeDefined ( ) ;
59- expect ( updatedTable . Table . BillingModeSummary . BillingMode ) . toBe ( 'PROVISIONED' ) ;
60- expect ( updatedTable . Table . GlobalSecondaryIndexes [ 0 ] . IndexName ) . toBe ( 'byName2' ) ;
61- expect ( updatedTable . Table . SSEDescription . Status ) . toBe ( 'ENABLED' ) ;
62- expect ( updatedTable . Table . StreamSpecification . StreamViewType ) . toBe ( 'KEYS_ONLY' ) ;
56+ const updateTemplatePath = path . resolve ( path . join ( __dirname , 'backends' , 'amplify-table' , 'simple-todo' , 'updateIndex' ) ) ;
57+ updateCDKAppWithTemplate ( projRoot , updateTemplatePath ) ;
58+ await cdkDeploy ( projRoot , '--all' , { timeoutMs : DURATION_30_MINUTES } ) ;
59+ const updatedTable = await getDDBTable ( tableName , region ) ;
60+ expect ( updatedTable ) . toBeDefined ( ) ;
61+ expect ( updatedTable . Table . BillingModeSummary . BillingMode ) . toBe ( 'PROVISIONED' ) ;
62+ expect ( updatedTable . Table . GlobalSecondaryIndexes [ 0 ] . IndexName ) . toBe ( 'byName2' ) ;
63+ expect ( updatedTable . Table . SSEDescription . Status ) . toBe ( 'ENABLED' ) ;
64+ expect ( updatedTable . Table . StreamSpecification . StreamViewType ) . toBe ( 'KEYS_ONLY' ) ;
6365
64- // Verify the tags on the table after update
65- const updatedTableTags = await getDDBTableTags ( updatedTable . Table . TableArn , region ) ;
66- expect ( updatedTableTags . Tags ) . toBeDefined ( ) ;
67- expect ( updatedTableTags . Tags . length ) . toBe ( 5 ) ;
68- expect ( updatedTableTags . Tags ) . toEqual (
69- expect . arrayContaining ( [
70- { Key : 'amplify:deployment-type' , Value : 'pipeline-updated' } ,
71- { Key : 'amplify:deployment-branch' , Value : 'main-updated' } ,
72- { Key : 'amplify:appId' , Value : '123456-updated' } ,
73- { Key : 'amplify:friendly-name' , Value : 'amplifyData-updated' } ,
74- { Key : 'created-by' , Value : 'amplify-updated' } ,
75- ] ) ,
76- ) ;
77- } , DURATION_45_MINUTES ) ;
66+ // Verify the tags on the table after update
67+ const updatedTableTags = await getDDBTableTags ( updatedTable . Table . TableArn , region ) ;
68+ expect ( updatedTableTags . Tags ) . toBeDefined ( ) ;
69+ expect ( updatedTableTags . Tags . length ) . toBe ( 5 ) ;
70+ expect ( updatedTableTags . Tags ) . toEqual (
71+ expect . arrayContaining ( [
72+ { Key : 'amplify:deployment-type' , Value : 'pipeline-updated' } ,
73+ { Key : 'amplify:deployment-branch' , Value : 'main-updated' } ,
74+ { Key : 'amplify:appId' , Value : '123456-updated' } ,
75+ { Key : 'amplify:friendly-name' , Value : 'amplifyData-updated' } ,
76+ { Key : 'created-by' , Value : 'amplify-updated' } ,
77+ ] ) ,
78+ ) ;
79+ } ,
80+ DURATION_45_MINUTES ,
81+ ) ;
7882} ) ;
0 commit comments