Skip to content

Commit e0f0b60

Browse files
author
Dane Pilcher
authored
fix: improve migration import error message (#3140)
1 parent 677a19f commit e0f0b60

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

packages/amplify-graphql-api-construct-tests/src/__tests__/migration/migration-validation.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ describe('Migration table import validation', () => {
7474
'extraGSIOnGen2',
7575
'',
7676
[
77-
'AttributeDefinitions does not match the expected value.\nActual: [{"AttributeName":"id","AttributeType":"S"}]\nExpected: [{"AttributeType":"S","AttributeName":"id"},{"AttributeType":"S","AttributeName":"content"}]',
78-
'GlobalSecondaryIndexes does not match the expected value.\nActual: undefined\nExpected: [{"IndexName":"todosByContent","KeySchema":[{"AttributeName":"content","KeyType":"HASH"}],"Projection":{"ProjectionType":"ALL"},"ProvisionedThroughput":{"ReadCapacityUnits":0,"WriteCapacityUnits":0}}]',
77+
'AttributeDefinitions does not match the expected value.\nImported Value: [{"AttributeName":"id","AttributeType":"S"}]\nExpected: [{"AttributeType":"S","AttributeName":"id"},{"AttributeType":"S","AttributeName":"content"}]',
78+
'GlobalSecondaryIndexes does not match the expected value.\nImported Value: undefined\nExpected: [{"IndexName":"todosByContent","KeySchema":[{"AttributeName":"content","KeyType":"HASH"}],"Projection":{"ProjectionType":"ALL"},"ProvisionedThroughput":{"ReadCapacityUnits":0,"WriteCapacityUnits":0}}]',
7979
],
8080
],
8181
[
@@ -90,7 +90,7 @@ describe('Migration table import validation', () => {
9090
};
9191
`,
9292
[
93-
'BillingModeSummary does not match the expected value.\nActual: {"BillingMode":"PAY_PER_REQUEST"}\nExpected: {"BillingMode":"PROVISIONED"}',
93+
'BillingModeSummary does not match the expected value.\nImported Value: {"BillingMode":"PAY_PER_REQUEST"}\nExpected: {"BillingMode":"PROVISIONED"}',
9494
],
9595
],
9696
[
@@ -105,7 +105,7 @@ describe('Migration table import validation', () => {
105105
};
106106
`,
107107
[
108-
'KeySchema does not match the expected value.\nActual: [{"AttributeName":"id","KeyType":"HASH"}]\nExpected: [{"AttributeName":"fakekey","KeyType":"HASH"}]',
108+
'KeySchema does not match the expected value.\nImported Value: [{"AttributeName":"id","KeyType":"HASH"}]\nExpected: [{"AttributeName":"fakekey","KeyType":"HASH"}]',
109109
],
110110
],
111111
[
@@ -123,7 +123,7 @@ describe('Migration table import validation', () => {
123123
};
124124
`,
125125
[
126-
'ProvisionedThroughput does not match the expected value.\nActual: {"ReadCapacityUnits":0,"WriteCapacityUnits":0}\nExpected: {"WriteCapacityUnits":5,"ReadCapacityUnits":5}',
126+
'ProvisionedThroughput does not match the expected value.\nImported Value: {"ReadCapacityUnits":0,"WriteCapacityUnits":0}\nExpected: {"WriteCapacityUnits":5,"ReadCapacityUnits":5}',
127127
],
128128
],
129129
[
@@ -140,13 +140,13 @@ describe('Migration table import validation', () => {
140140
};
141141
`,
142142
[
143-
'StreamSpecification does not match the expected value.\nActual: {"StreamEnabled":true,"StreamViewType":"NEW_AND_OLD_IMAGES"}\nExpected: {"StreamEnabled":true,"StreamViewType":"KEYS_ONLY"}',
143+
'StreamSpecification does not match the expected value.\nImported Value: {"StreamEnabled":true,"StreamViewType":"NEW_AND_OLD_IMAGES"}\nExpected: {"StreamEnabled":true,"StreamViewType":"KEYS_ONLY"}',
144144
],
145145
],
146146
[
147147
'sseDescription',
148148
'',
149-
['SSEDescription does not match the expected value.\nActual: undefined\nExpected: {"SSEType":"KMS","Status":"ENABLED"}'],
149+
['SSEDescription does not match the expected value.\nImported Value: undefined\nExpected: {"SSEType":"KMS","Status":"ENABLED"}'],
150150
],
151151
[
152152
'deletionProtectionEnabled',
@@ -159,7 +159,7 @@ describe('Migration table import validation', () => {
159159
todoTable.addOverride('Properties.deletionProtectionEnabled', true);
160160
};
161161
`,
162-
['DeletionProtectionEnabled does not match the expected value.\nActual: false\nExpected: true'],
162+
['DeletionProtectionEnabled does not match the expected value.\nImported Value: false\nExpected: true'],
163163
],
164164
];
165165
test.each(testCases)('%s', async (testCaseName, overrides, expectedErrors) => {

packages/amplify-graphql-model-transformer/src/__tests__/import-table.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ describe('import-table', () => {
358358
.toThrowErrorMatchingInlineSnapshot(`
359359
"Imported table properties did not match the expected table properties.
360360
AttributeDefinitions does not match the expected value.
361-
Actual: [{\\"AttributeName\\":\\"todoId\\",\\"AttributeType\\":\\"S\\"},{\\"AttributeName\\":\\"name\\",\\"AttributeType\\":\\"S\\"},{\\"AttributeName\\":\\"name2\\",\\"AttributeType\\":\\"S\\"}]
361+
Imported Value: [{\\"AttributeName\\":\\"todoId\\",\\"AttributeType\\":\\"S\\"},{\\"AttributeName\\":\\"name\\",\\"AttributeType\\":\\"S\\"},{\\"AttributeName\\":\\"name2\\",\\"AttributeType\\":\\"S\\"}]
362362
Expected: [{\\"AttributeName\\":\\"todoId\\",\\"AttributeType\\":\\"S\\"},{\\"AttributeName\\":\\"differentName\\",\\"AttributeType\\":\\"S\\"},{\\"AttributeName\\":\\"name2\\",\\"AttributeType\\":\\"S\\"}]"
363363
`);
364364
});
@@ -396,7 +396,7 @@ describe('import-table', () => {
396396
.toThrowErrorMatchingInlineSnapshot(`
397397
"Imported table properties did not match the expected table properties.
398398
KeySchema does not match the expected value.
399-
Actual: [{\\"AttributeName\\":\\"todoId\\",\\"KeyType\\":\\"HASH\\"},{\\"AttributeName\\":\\"name\\",\\"KeyType\\":\\"RANGE\\"}]
399+
Imported Value: [{\\"AttributeName\\":\\"todoId\\",\\"KeyType\\":\\"HASH\\"},{\\"AttributeName\\":\\"name\\",\\"KeyType\\":\\"RANGE\\"}]
400400
Expected: [{\\"AttributeName\\":\\"todoId\\",\\"KeyType\\":\\"HASH\\"},{\\"AttributeName\\":\\"differentName\\",\\"KeyType\\":\\"RANGE\\"}]"
401401
`);
402402
});
@@ -450,7 +450,7 @@ describe('import-table', () => {
450450
.toThrowErrorMatchingInlineSnapshot(`
451451
"Imported table properties did not match the expected table properties.
452452
GlobalSecondaryIndexes does not match the expected value.
453-
Actual: [{\\"IndexName\\":\\"byName2\\",\\"KeySchema\\":[{\\"AttributeName\\":\\"name2\\",\\"KeyType\\":\\"HASH\\"}],\\"Projection\\":{\\"ProjectionType\\":\\"ALL\\"},\\"ProvisionedThroughput\\":{\\"ReadCapacityUnits\\":5,\\"WriteCapacityUnits\\":5}}]
453+
Imported Value: [{\\"IndexName\\":\\"byName2\\",\\"KeySchema\\":[{\\"AttributeName\\":\\"name2\\",\\"KeyType\\":\\"HASH\\"}],\\"Projection\\":{\\"ProjectionType\\":\\"ALL\\"},\\"ProvisionedThroughput\\":{\\"ReadCapacityUnits\\":5,\\"WriteCapacityUnits\\":5}}]
454454
Expected: [{\\"IndexName\\":\\"byName2\\",\\"KeySchema\\":[{\\"AttributeName\\":\\"name2\\",\\"KeyType\\":\\"HASH\\"}],\\"Projection\\":{\\"ProjectionType\\":\\"ALL\\"},\\"ProvisionedThroughput\\":{\\"ReadCapacityUnits\\":5,\\"WriteCapacityUnits\\":10}}]"
455455
`);
456456
});
@@ -476,7 +476,7 @@ describe('import-table', () => {
476476
.toThrowErrorMatchingInlineSnapshot(`
477477
"Imported table properties did not match the expected table properties.
478478
BillingModeSummary does not match the expected value.
479-
Actual: {\\"BillingMode\\":\\"PROVISIONED\\"}
479+
Imported Value: {\\"BillingMode\\":\\"PROVISIONED\\"}
480480
Expected: {\\"BillingMode\\":\\"PAY_PER_REQUEST\\"}"
481481
`);
482482
});
@@ -506,7 +506,7 @@ describe('import-table', () => {
506506
.toThrowErrorMatchingInlineSnapshot(`
507507
"Imported table properties did not match the expected table properties.
508508
ProvisionedThroughput does not match the expected value.
509-
Actual: {\\"ReadCapacityUnits\\":5,\\"WriteCapacityUnits\\":5}
509+
Imported Value: {\\"ReadCapacityUnits\\":5,\\"WriteCapacityUnits\\":5}
510510
Expected: {\\"ReadCapacityUnits\\":5,\\"WriteCapacityUnits\\":10}"
511511
`);
512512
});
@@ -532,7 +532,7 @@ describe('import-table', () => {
532532
.toThrowErrorMatchingInlineSnapshot(`
533533
"Imported table properties did not match the expected table properties.
534534
StreamSpecification does not match the expected value.
535-
Actual: {\\"StreamEnabled\\":true,\\"StreamViewType\\":\\"NEW_AND_OLD_IMAGES\\"}
535+
Imported Value: {\\"StreamEnabled\\":true,\\"StreamViewType\\":\\"NEW_AND_OLD_IMAGES\\"}
536536
Expected: {\\"StreamEnabled\\":false,\\"StreamViewType\\":\\"NEW_AND_OLD_IMAGES\\"}"
537537
`);
538538
});
@@ -551,7 +551,7 @@ describe('import-table', () => {
551551
.toThrowErrorMatchingInlineSnapshot(`
552552
"Imported table properties did not match the expected table properties.
553553
SSEDescription does not match the expected value.
554-
Actual: undefined
554+
Imported Value: undefined
555555
Expected: {\\"SSEType\\":\\"KMS\\"}"
556556
`);
557557
});
@@ -568,7 +568,7 @@ describe('import-table', () => {
568568
.toThrowErrorMatchingInlineSnapshot(`
569569
"Imported table properties did not match the expected table properties.
570570
DeletionProtectionEnabled does not match the expected value.
571-
Actual: true
571+
Imported Value: true
572572
Expected: false"
573573
`);
574574
});
@@ -589,10 +589,10 @@ describe('import-table', () => {
589589
.toThrowErrorMatchingInlineSnapshot(`
590590
"Imported table properties did not match the expected table properties.
591591
SSEDescription does not match the expected value.
592-
Actual: undefined
592+
Imported Value: undefined
593593
Expected: {\\"SSEType\\":\\"KMS\\"}
594594
DeletionProtectionEnabled does not match the expected value.
595-
Actual: true
595+
Imported Value: true
596596
Expected: false"
597597
`);
598598
});

packages/amplify-graphql-model-transformer/src/resources/amplify-dynamodb-table/amplify-table-manager-lambda/import-table.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export const validateImportedTableProperties = (
5050
): void => {
5151
if (!isEqual(imported, expected)) {
5252
errors.push(
53-
`${propertyName} does not match the expected value.\nActual: ${JSON.stringify(imported)}\nExpected: ${JSON.stringify(expected)}`,
53+
`${propertyName} does not match the expected value.\nImported Value: ${JSON.stringify(imported)}\nExpected: ${JSON.stringify(
54+
expected,
55+
)}`,
5456
);
5557
}
5658
};

0 commit comments

Comments
 (0)