Skip to content

Commit 04b5928

Browse files
committed
fix: run prettier on amplify-table test files
The PR lint check failed because amplify-table-1.test.ts and amplify-table-5.test.ts had Prettier formatting issues (test function argument wrapping). Run prettier --write to fix.
1 parent c810c29 commit 04b5928

2 files changed

Lines changed: 88 additions & 80 deletions

File tree

packages/amplify-graphql-api-construct-tests/src/__tests__/amplify-table-1.test.ts

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -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
});

packages/amplify-graphql-api-construct-tests/src/__tests__/amplify-table-5.test.ts

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,41 @@ describe('CDK amplify table 5', () => {
2424
deleteProjectDir(projRoot);
2525
});
2626

27-
test('datatype change on indexed field should replace the index', 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.Table.AttributeDefinitions).toHaveLength(2);
35-
const nameAttr = table.Table.AttributeDefinitions.find((attr) => attr.AttributeName === 'name');
36-
expect(nameAttr.AttributeType).toEqual('S');
37-
expect(table.Table.GlobalSecondaryIndexes).toHaveLength(1);
38-
expect(table.Table.GlobalSecondaryIndexes[0].IndexName).toEqual('byName');
27+
test(
28+
'datatype change on indexed field should replace the index',
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.Table.AttributeDefinitions).toHaveLength(2);
37+
const nameAttr = table.Table.AttributeDefinitions.find((attr) => attr.AttributeName === 'name');
38+
expect(nameAttr.AttributeType).toEqual('S');
39+
expect(table.Table.GlobalSecondaryIndexes).toHaveLength(1);
40+
expect(table.Table.GlobalSecondaryIndexes[0].IndexName).toEqual('byName');
3941

40-
// deploy with modified attribute type
41-
const updateTemplatePath = path.resolve(path.join(__dirname, 'backends', 'amplify-table', 'simple-todo', 'attributeTypeChange'));
42-
updateCDKAppWithTemplate(projRoot, updateTemplatePath);
43-
await cdkDeploy(projRoot, '--all', { timeoutMs: DURATION_30_MINUTES });
44-
const modifiedTable = await getDDBTable(tableName, region);
45-
expect(modifiedTable.Table.AttributeDefinitions).toHaveLength(3);
46-
const modifiedNameAttr = modifiedTable.Table.AttributeDefinitions.find((attr) => attr.AttributeName === 'name');
47-
expect(modifiedNameAttr.AttributeType).toEqual('N');
48-
expect(modifiedTable.Table.GlobalSecondaryIndexes).toHaveLength(2);
49-
expect(modifiedTable.Table.GlobalSecondaryIndexes).toEqual(
50-
expect.arrayContaining([
51-
expect.objectContaining({
52-
IndexName: 'byNameDescription',
53-
}),
54-
expect.objectContaining({
55-
IndexName: 'byName',
56-
}),
57-
]),
58-
);
59-
}, DURATION_45_MINUTES);
42+
// deploy with modified attribute type
43+
const updateTemplatePath = path.resolve(path.join(__dirname, 'backends', 'amplify-table', 'simple-todo', 'attributeTypeChange'));
44+
updateCDKAppWithTemplate(projRoot, updateTemplatePath);
45+
await cdkDeploy(projRoot, '--all', { timeoutMs: DURATION_30_MINUTES });
46+
const modifiedTable = await getDDBTable(tableName, region);
47+
expect(modifiedTable.Table.AttributeDefinitions).toHaveLength(3);
48+
const modifiedNameAttr = modifiedTable.Table.AttributeDefinitions.find((attr) => attr.AttributeName === 'name');
49+
expect(modifiedNameAttr.AttributeType).toEqual('N');
50+
expect(modifiedTable.Table.GlobalSecondaryIndexes).toHaveLength(2);
51+
expect(modifiedTable.Table.GlobalSecondaryIndexes).toEqual(
52+
expect.arrayContaining([
53+
expect.objectContaining({
54+
IndexName: 'byNameDescription',
55+
}),
56+
expect.objectContaining({
57+
IndexName: 'byName',
58+
}),
59+
]),
60+
);
61+
},
62+
DURATION_45_MINUTES,
63+
);
6064
});

0 commit comments

Comments
 (0)