diff options
Diffstat (limited to 'jstests/core/timeseries/timeseries_delete_one.js')
-rw-r--r-- | jstests/core/timeseries/timeseries_delete_one.js | 81 |
1 files changed, 1 insertions, 80 deletions
diff --git a/jstests/core/timeseries/timeseries_delete_one.js b/jstests/core/timeseries/timeseries_delete_one.js index 39ad152a7d2..315f611e126 100644 --- a/jstests/core/timeseries/timeseries_delete_one.js +++ b/jstests/core/timeseries/timeseries_delete_one.js @@ -11,86 +11,7 @@ (function() { "use strict"; -const timeFieldName = "time"; -const metaFieldName = "tag"; -const dateTime = ISODate("2021-07-12T16:00:00Z"); -const collNamePrefix = "timeseries_delete_one_"; -let testCaseId = 0; - -const testDB = db.getSiblingDB(jsTestName()); -assert.commandWorked(testDB.dropDatabase()); - -/** - * Confirms that a deleteOne() returns the expected set of documents. - */ -function testDeleteOne({initialDocList, filter, expectedResultDocs, nDeleted}) { - const coll = testDB.getCollection(collNamePrefix + testCaseId++); - assert.commandWorked(testDB.createCollection( - coll.getName(), {timeseries: {timeField: timeFieldName, metaField: metaFieldName}})); - - assert.commandWorked(coll.insert(initialDocList)); - - const res = assert.commandWorked(coll.deleteOne(filter)); - assert.eq(nDeleted, res.deletedCount); - - const resultDocs = coll.find().toArray(); - assert.eq(resultDocs.length, initialDocList.length - nDeleted, tojson(resultDocs)); - - // Validate the collection's exact contents if we were given the expected results. We may skip - // this step in some cases, if the delete doesn't pinpoint a specific document. - if (expectedResultDocs) { - assert.eq(expectedResultDocs.length, resultDocs.length, resultDocs); - expectedResultDocs.forEach(expectedDoc => { - assert.docEq( - expectedDoc, - coll.findOne({_id: expectedDoc._id}), - `Expected document (_id = ${expectedDoc._id}) not found in result collection: ${ - tojson(resultDocs)}`); - }); - } -} - -const doc1_a_nofields = { - _id: 1, - [timeFieldName]: dateTime, - [metaFieldName]: "A", -}; -const doc2_a_f101 = { - _id: 2, - [timeFieldName]: dateTime, - [metaFieldName]: "A", - f: 101 -}; -const doc3_a_f102 = { - _id: 3, - [timeFieldName]: dateTime, - [metaFieldName]: "A", - f: 102 -}; -const doc4_b_f103 = { - _id: 4, - [timeFieldName]: dateTime, - [metaFieldName]: "B", - f: 103 -}; -const doc5_b_f104 = { - _id: 5, - [timeFieldName]: dateTime, - [metaFieldName]: "B", - f: 104 -}; -const doc6_c_f105 = { - _id: 6, - [timeFieldName]: dateTime, - [metaFieldName]: "C", - f: 105 -}; -const doc7_c_f106 = { - _id: 7, - [timeFieldName]: dateTime, - [metaFieldName]: "C", - f: 106, -}; +load("jstests/core/timeseries/libs/timeseries_writes_util.js"); // Query on the 'f' field leads to zero measurement delete. (function testZeroMeasurementDelete() { |