Skip to content

Commit e383701

Browse files
test(deleteReferences): Add test for optional primary key
1 parent 611df8f commit e383701

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

test/unit.test.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,22 @@ testsuites.forEach(testsuite => {
7474
async function testPrimaryKey(sut, t, name) {
7575
// Test one key
7676
let targetCollection = 'collection/{collectionId}';
77-
let primaryKey = getPrimaryKey(targetCollection);
77+
let result = getPrimaryKey(targetCollection);
7878

79-
t.is(primaryKey, 'collectionId');
79+
t.true(result.hasPrimaryKey);
80+
t.is(result.primaryKey, 'collectionId');
8081

8182
// Test two keys
8283
targetCollection = 'collection/{collectionId}/some_detail/{detailId}';
83-
primaryKey = getPrimaryKey(targetCollection);
84-
t.is(primaryKey, 'detailId');
84+
result = getPrimaryKey(targetCollection);
85+
t.true(result.hasPrimaryKey);
86+
t.is(result.primaryKey, 'detailId');
8587

8688
// Test missing key
8789
targetCollection = 'collection';
88-
89-
const error = t.throws(() => {
90-
getPrimaryKey(targetCollection);
91-
});
92-
t.is(error.message, 'integrify: Missing a primary key in the source');
90+
result = getPrimaryKey(targetCollection);
91+
t.false(result.hasPrimaryKey);
92+
t.is(result.primaryKey, 'masterId');
9393

9494
await t.pass();
9595
}
@@ -430,7 +430,10 @@ async function testDeleteMissingSourceCollectionKey(sut, t, name) {
430430
});
431431
});
432432

433-
t.is(error.message, 'integrify: Missing a primary key in the source');
433+
t.is(
434+
error.message,
435+
'integrify: Missing a primary key [masterId] in the source params'
436+
);
434437

435438
// Assert pre-hook was called (only for rules-in-situ)
436439
if (name === 'rules-in-situ') {

0 commit comments

Comments
 (0)