@sprucelabs/data-stores 28.3.274 → 28.3.276
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -341,19 +341,19 @@ const databaseAssertUtil = {
|
|
341
341
|
const matchedBeforeDelete = yield db.findOne(this.collectionName, {
|
342
342
|
id: created.id,
|
343
343
|
});
|
344
|
-
assert.isTruthy(matchedBeforeDelete);
|
345
|
-
assert.isEqual(matchedBeforeDelete.id, created.id);
|
344
|
+
assert.isTruthy(matchedBeforeDelete, 'findOne() did not return the record created!');
|
345
|
+
assert.isEqual(matchedBeforeDelete.id, created.id, 'findOne() returned id does not match what was sent to createOne');
|
346
346
|
const numDeleted = yield db.delete(this.collectionName, {
|
347
347
|
id: matchedBeforeDelete.id,
|
348
348
|
});
|
349
|
-
assert.isEqual(numDeleted, 1);
|
349
|
+
assert.isEqual(numDeleted, 1, 'delete() did not return the total recrods deleted!');
|
350
350
|
const matchedAfterDelete = yield db.findOne(this.collectionName, {
|
351
351
|
id: created.id,
|
352
352
|
});
|
353
|
-
assert.isFalsy(matchedAfterDelete, `Record with the id of ${created.id} was not deleted!`);
|
353
|
+
assert.isFalsy(matchedAfterDelete, `Record with the id of ${created.id} was not deleted with delete()!`);
|
354
354
|
yield db.create(this.collectionName, [
|
355
355
|
{
|
356
|
-
name: '
|
356
|
+
name: 'another record',
|
357
357
|
},
|
358
358
|
{
|
359
359
|
name: 'a record',
|
@@ -362,8 +362,12 @@ const databaseAssertUtil = {
|
|
362
362
|
name: 'a record',
|
363
363
|
},
|
364
364
|
]);
|
365
|
-
const manyDeleted = yield db.delete(this.collectionName, {
|
366
|
-
|
365
|
+
const manyDeleted = yield db.delete(this.collectionName, {
|
366
|
+
name: 'another record',
|
367
|
+
});
|
368
|
+
assert.isEqual(manyDeleted, 1, `delete() did not return the total records deleted!`);
|
369
|
+
const total = yield db.count(this.collectionName);
|
370
|
+
assert.isEqual(total, 2, 'delete() did not delete all records');
|
367
371
|
yield this.shutdown(db);
|
368
372
|
});
|
369
373
|
},
|
@@ -1254,19 +1258,19 @@ const databaseAssertUtil = {
|
|
1254
1258
|
const gteMatches = yield db.find(this.collectionName, {
|
1255
1259
|
number: { $gte: created[2].number },
|
1256
1260
|
});
|
1257
|
-
assert.isLength(gteMatches, 2);
|
1261
|
+
assert.isLength(gteMatches, 2, 'find() did not return the expected 2 using $gte.');
|
1258
1262
|
assert.isEqual(gteMatches[0].number, 3);
|
1259
1263
|
assert.isEqual(gteMatches[1].number, 4);
|
1260
1264
|
const ltMatches = yield db.find(this.collectionName, {
|
1261
1265
|
number: { $lt: created[2].number },
|
1262
1266
|
});
|
1263
|
-
assert.isLength(ltMatches, 2);
|
1267
|
+
assert.isLength(ltMatches, 2, 'find() did not return the expected 2 using $lt.');
|
1264
1268
|
assert.isEqual(ltMatches[0].number, 1);
|
1265
1269
|
assert.isEqual(ltMatches[1].number, 2);
|
1266
1270
|
const lteMatches = yield db.find(this.collectionName, {
|
1267
1271
|
number: { $lte: created[2].number },
|
1268
1272
|
});
|
1269
|
-
assert.isLength(lteMatches, 3);
|
1273
|
+
assert.isLength(lteMatches, 3, 'find() did not return the expected 3 using $lte.');
|
1270
1274
|
assert.isEqual(lteMatches[0].number, 1);
|
1271
1275
|
assert.isEqual(lteMatches[1].number, 2);
|
1272
1276
|
assert.isEqual(lteMatches[2].number, 3);
|
@@ -1275,14 +1279,14 @@ const databaseAssertUtil = {
|
|
1275
1279
|
$ne: created[0].id,
|
1276
1280
|
},
|
1277
1281
|
});
|
1278
|
-
assert.isNotEqual(notMatches[0].id, created[0].id);
|
1279
|
-
assert.isLength(notMatches, created.length - 1);
|
1282
|
+
assert.isNotEqual(notMatches[0].id, created[0].id, '$ne did not return the expected results.');
|
1283
|
+
assert.isLength(notMatches, created.length - 1, '$ne did not return the expected results.');
|
1280
1284
|
const notNull = yield db.find(this.collectionName, {
|
1281
1285
|
someField: {
|
1282
1286
|
$ne: null,
|
1283
1287
|
},
|
1284
1288
|
});
|
1285
|
-
assert.isLength(notNull, created.length - 1);
|
1289
|
+
assert.isLength(notNull, created.length - 1, '$ne=null did not return the expected results.');
|
1286
1290
|
yield this.shutdown(db);
|
1287
1291
|
});
|
1288
1292
|
},
|
@@ -310,19 +310,19 @@ const databaseAssertUtil = {
|
|
310
310
|
const matchedBeforeDelete = await db.findOne(this.collectionName, {
|
311
311
|
id: created.id,
|
312
312
|
});
|
313
|
-
test_utils_1.assert.isTruthy(matchedBeforeDelete);
|
314
|
-
test_utils_1.assert.isEqual(matchedBeforeDelete.id, created.id);
|
313
|
+
test_utils_1.assert.isTruthy(matchedBeforeDelete, 'findOne() did not return the record created!');
|
314
|
+
test_utils_1.assert.isEqual(matchedBeforeDelete.id, created.id, 'findOne() returned id does not match what was sent to createOne');
|
315
315
|
const numDeleted = await db.delete(this.collectionName, {
|
316
316
|
id: matchedBeforeDelete.id,
|
317
317
|
});
|
318
|
-
test_utils_1.assert.isEqual(numDeleted, 1);
|
318
|
+
test_utils_1.assert.isEqual(numDeleted, 1, 'delete() did not return the total recrods deleted!');
|
319
319
|
const matchedAfterDelete = await db.findOne(this.collectionName, {
|
320
320
|
id: created.id,
|
321
321
|
});
|
322
|
-
test_utils_1.assert.isFalsy(matchedAfterDelete, `Record with the id of ${created.id} was not deleted!`);
|
322
|
+
test_utils_1.assert.isFalsy(matchedAfterDelete, `Record with the id of ${created.id} was not deleted with delete()!`);
|
323
323
|
await db.create(this.collectionName, [
|
324
324
|
{
|
325
|
-
name: '
|
325
|
+
name: 'another record',
|
326
326
|
},
|
327
327
|
{
|
328
328
|
name: 'a record',
|
@@ -331,8 +331,12 @@ const databaseAssertUtil = {
|
|
331
331
|
name: 'a record',
|
332
332
|
},
|
333
333
|
]);
|
334
|
-
const manyDeleted = await db.delete(this.collectionName, {
|
335
|
-
|
334
|
+
const manyDeleted = await db.delete(this.collectionName, {
|
335
|
+
name: 'another record',
|
336
|
+
});
|
337
|
+
test_utils_1.assert.isEqual(manyDeleted, 1, `delete() did not return the total records deleted!`);
|
338
|
+
const total = await db.count(this.collectionName);
|
339
|
+
test_utils_1.assert.isEqual(total, 2, 'delete() did not delete all records');
|
336
340
|
await this.shutdown(db);
|
337
341
|
},
|
338
342
|
async assertCanLimitResultsToZero(connect) {
|
@@ -1147,19 +1151,19 @@ const databaseAssertUtil = {
|
|
1147
1151
|
const gteMatches = await db.find(this.collectionName, {
|
1148
1152
|
number: { $gte: created[2].number },
|
1149
1153
|
});
|
1150
|
-
test_utils_1.assert.isLength(gteMatches, 2);
|
1154
|
+
test_utils_1.assert.isLength(gteMatches, 2, 'find() did not return the expected 2 using $gte.');
|
1151
1155
|
test_utils_1.assert.isEqual(gteMatches[0].number, 3);
|
1152
1156
|
test_utils_1.assert.isEqual(gteMatches[1].number, 4);
|
1153
1157
|
const ltMatches = await db.find(this.collectionName, {
|
1154
1158
|
number: { $lt: created[2].number },
|
1155
1159
|
});
|
1156
|
-
test_utils_1.assert.isLength(ltMatches, 2);
|
1160
|
+
test_utils_1.assert.isLength(ltMatches, 2, 'find() did not return the expected 2 using $lt.');
|
1157
1161
|
test_utils_1.assert.isEqual(ltMatches[0].number, 1);
|
1158
1162
|
test_utils_1.assert.isEqual(ltMatches[1].number, 2);
|
1159
1163
|
const lteMatches = await db.find(this.collectionName, {
|
1160
1164
|
number: { $lte: created[2].number },
|
1161
1165
|
});
|
1162
|
-
test_utils_1.assert.isLength(lteMatches, 3);
|
1166
|
+
test_utils_1.assert.isLength(lteMatches, 3, 'find() did not return the expected 3 using $lte.');
|
1163
1167
|
test_utils_1.assert.isEqual(lteMatches[0].number, 1);
|
1164
1168
|
test_utils_1.assert.isEqual(lteMatches[1].number, 2);
|
1165
1169
|
test_utils_1.assert.isEqual(lteMatches[2].number, 3);
|
@@ -1168,14 +1172,14 @@ const databaseAssertUtil = {
|
|
1168
1172
|
$ne: created[0].id,
|
1169
1173
|
},
|
1170
1174
|
});
|
1171
|
-
test_utils_1.assert.isNotEqual(notMatches[0].id, created[0].id);
|
1172
|
-
test_utils_1.assert.isLength(notMatches, created.length - 1);
|
1175
|
+
test_utils_1.assert.isNotEqual(notMatches[0].id, created[0].id, '$ne did not return the expected results.');
|
1176
|
+
test_utils_1.assert.isLength(notMatches, created.length - 1, '$ne did not return the expected results.');
|
1173
1177
|
const notNull = await db.find(this.collectionName, {
|
1174
1178
|
someField: {
|
1175
1179
|
$ne: null,
|
1176
1180
|
},
|
1177
1181
|
});
|
1178
|
-
test_utils_1.assert.isLength(notNull, created.length - 1);
|
1182
|
+
test_utils_1.assert.isLength(notNull, created.length - 1, '$ne=null did not return the expected results.');
|
1179
1183
|
await this.shutdown(db);
|
1180
1184
|
},
|
1181
1185
|
async assertCanFindWithNe(connect) {
|