diff --git a/test/integration/causal-consistency/causal_consistency.prose.test.js b/test/integration/causal-consistency/causal_consistency.prose.test.js index bc7bbeed6e..f4932b12a2 100644 --- a/test/integration/causal-consistency/causal_consistency.prose.test.js +++ b/test/integration/causal-consistency/causal_consistency.prose.test.js @@ -169,7 +169,7 @@ describe('Causal Consistency - prose tests', function () { let firstOperationTime; return db .collection('causal_test') - .insert({}, { session: session }) + .insertOne({}, { session: session }) .then(() => { firstOperationTime = test.commands.succeeded[0].reply.operationTime; return db.collection('causal_test').findOne({}, { session: session }); diff --git a/test/integration/crud/bulk.test.ts b/test/integration/crud/bulk.test.ts index 1d9b6c3da2..054011ee1d 100644 --- a/test/integration/crud/bulk.test.ts +++ b/test/integration/crud/bulk.test.ts @@ -1376,22 +1376,6 @@ describe('Bulk', function () { expect(error).to.have.property('message', 'Invalid BulkOperation, Batch cannot be empty'); }); - // TODO(NODE-7219): remove outdated test - // it('should return an error instead of throwing when an empty bulk operation is submitted (with promise)', function () { - // return client - // .db() - // .collection('doesnt_matter') - // .insertMany([]) - // - // .then(function () { - // test.equal(false, true); // this should not happen! - // }) - // .catch(function (err) { - // expect(err).to.be.instanceOf(MongoDriverError); - // expect(err).to.have.property('message', 'Invalid BulkOperation, Batch cannot be empty'); - // }); - // }); - it('should properly account for array key size in bulk unordered inserts', async function () { const documents = new Array(20000).fill('').map(() => ({ arr: new Array(19).fill('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') diff --git a/test/integration/crud/crud_api.test.ts b/test/integration/crud/crud_api.test.ts index d4163d32cb..cedea9d867 100644 --- a/test/integration/crud/crud_api.test.ts +++ b/test/integration/crud/crud_api.test.ts @@ -315,35 +315,6 @@ describe('CRUD API', function () { await db.collection('t1').drop(); }); - // TODO(NODE-7219): Remove test as it doesn't test correct aggregation execution - // it('allMethods', async function () { - // const cursor = db.collection('t1').aggregate([{ $match: {} }], { - // allowDiskUse: true, - // batchSize: 2, - // maxTimeMS: 50 - // }); - // - // // Exercise all the options - // cursor - // .geoNear({ geo: 1 }) - // .group({ group: 1 }) - // .limit(10) - // .match({ match: 1 }) - // .maxTimeMS(10) - // .out('collection') - // .project({ project: 1 }) - // .redact({ redact: 1 }) - // .skip(1) - // .sort({ sort: 1 }) - // .batchSize(10) - // .unwind('name'); - // - // // Execute the command with all steps defined - // // will fail - // const err = await cursor.toArray().catch(err => err); - // expect(err).to.be.instanceof(MongoServerError); - // }); - it('#toArray()', async function () { const cursor = db.collection('t1').aggregate(); cursor.match({ a: 1 }); @@ -477,15 +448,6 @@ describe('CRUD API', function () { }); describe('should correctly execute update methods using crud api', function () { - // TODO(NODE-7219): Remove test. There is no `update` method anymore - // it('legacy update', async function () { - // const db = client.db(); - // const r = await db - // .collection('t3_1') - // .update({ a: 1 }, { $set: { a: 2 } }, { upsert: true }); - // expect(r).property('upsertedCount').to.equal(1); - // }); - it('#updateOne()', async function () { const db = client.db(); const i = await db.collection('t3_2').insertMany([{ c: 1 }], { writeConcern: { w: 1 } }); @@ -805,25 +767,6 @@ describe('CRUD API', function () { test.ok(r != null); }); - // TODO(NODE-7219): Remove test as it duplicates the one from the above - // it('should correctly execute crud operations using w:0', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded'] } - // }, - // - // test: async function () { - // const db = client.db(); - // - // const collection = db.collection<{ _id: number }>('w0crudoperations'); - // const r = await collection.updateOne( - // { _id: 1 }, - // { $set: { x: 1 } }, - // { upsert: true, writeConcern: { w: 0 } } - // ); - // test.ok(r != null); - // } - // }); - describe('when performing a multi-batch unordered bulk write that has a duplicate key', function () { it('throws a MongoBulkWriteError indicating the duplicate key document failed', async function () { const ops = []; diff --git a/test/integration/crud/find.test.ts b/test/integration/crud/find.test.ts index 9b794366ec..80e7f68d14 100644 --- a/test/integration/crud/find.test.ts +++ b/test/integration/crud/find.test.ts @@ -55,48 +55,6 @@ describe('Find', function () { expect(valuesBySelection[0].a).to.deep.equal(docs[0].a); }); - // TODO(NODE-7219): Remove test as it duplicates "should correctly perform simple find" - // it('shouldCorrectlyPerformSimpleChainedFind', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // var configuration = this.configuration; - // var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // var db = client.db(configuration.db); - // db.createCollection('test_find_simple_chained', function (err) { - // expect(err).to.not.exist; - // const collection = db.collection('test_find_simple_chained'); - // const docs = [{ a: 2 }, { b: 3 }]; - // - // // Insert some test documents - // collection.insert(docs, configuration.writeConcernMax(), err => { - // expect(err).to.not.exist; - // - // // Ensure correct insertion testing via the cursor and the count function - // collection.find().toArray(function (err, documents) { - // test.equal(2, documents.length); - // - // collection.count(function (err, count) { - // test.equal(2, count); - // - // // Fetch values by selection - // collection.find({ a: docs[0].a }).toArray(function (err, documents) { - // test.equal(1, documents.length); - // test.equal(docs[0].a, documents[0].a); - // // Let's close the db - // client.close(done); - // }); - // }); - // }); - // }); - // }); - // }); - // } - // }); - it('should correctly perform advanced finds', async function () { const configuration = this.configuration; @@ -387,106 +345,6 @@ describe('Find', function () { test.equal('mike', mike.hello); }); - // TODO(NODE-7219): Remove test as it duplicates other tests that testing nested documents - // it('shouldCorrectlyReturnDocumentWithOriginalStructure', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // var configuration = this.configuration; - // var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // var db = client.db(configuration.db); - // db.createCollection('test_find_by_oid_with_subdocs', function (err, collection) { - // var c1 = { _id: new ObjectId(), comments: [], title: 'number 1' }; - // var c2 = { _id: new ObjectId(), comments: [], title: 'number 2' }; - // var doc = { - // numbers: [], - // owners: [], - // comments: [c1, c2], - // _id: new ObjectId() - // }; - // - // collection.insert(doc, configuration.writeConcernMax(), function (err) { - // expect(err).to.not.exist; - // collection.findOne( - // { _id: doc._id }, - // { writeConcern: { w: 1 }, projection: undefined }, - // function (err, doc) { - // expect(err).to.not.exist; - // test.equal(2, doc.comments.length); - // test.equal('number 1', doc.comments[0].title); - // test.equal('number 2', doc.comments[1].title); - // - // client.close(done); - // } - // ); - // }); - // }); - // }); - // } - // }); - - // TODO(NODE-7219): Remove test as it duplicates simple find - // it('shouldCorrectlyRetrieveSingleRecord', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // var configuration = this.configuration; - // var p_client = configuration.newClient(configuration.writeConcernMax(), { - // maxPoolSize: 1 - // }); - // - // p_client.connect(function (err, client) { - // var db = client.db(configuration.db); - // - // db.createCollection( - // 'test_should_correctly_retrieve_one_record', - // function (err, collection) { - // collection.insert({ a: 0 }, configuration.writeConcernMax(), function (err) { - // expect(err).to.not.exist; - // const usercollection = db.collection('test_should_correctly_retrieve_one_record'); - // usercollection.findOne({ a: 0 }, function (err) { - // expect(err).to.not.exist; - // p_client.close(done); - // }); - // }); - // } - // ); - // }); - // } - // }); - - // TODO(NODE-7219): Remove test as it tests `createFromHexString` method of BSON - // it('shouldCorrectlyHandleError', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // var configuration = this.configuration; - // var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // var db = client.db(configuration.db); - // db.createCollection('test_find_one_error_handling', function (err, collection) { - // // Try to fetch an object using a totally invalid and wrong hex string... what we're interested in here - // // is the error handling of the findOne Method - // try { - // collection.findOne( - // { _id: ObjectId.createFromHexString('5e9bd59248305adf18ebc15703a1') }, - // function () {} - // ); - // } catch { - // client.close(done); - // } - // }); - // }); - // } - // }); - it('should correctly perform find with options', async function () { const configuration = this.configuration; const db = client.db(configuration.db); @@ -878,53 +736,6 @@ describe('Find', function () { expect(err.message).to.include('immutable field'); }); - // TODO(NODE-7219): Remove test as it doesn't test any find* operations - // it('shouldCorrectlyExecutefindOneAndUpdateUnderConcurrentLoad', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // var configuration = this.configuration; - // var p_client = configuration.newClient(configuration.writeConcernMax(), { - // maxPoolSize: 1 - // }); - // var running = true; - // - // p_client.connect(function (err, client) { - // var db = client.db(configuration.db); - // // Create a collection - // db.createCollection('collection1', function (err, collection) { - // // Wait a bit and then execute something that will throw a duplicate error - // setTimeout(function () { - // var id = new ObjectId(); - // - // collection.insert({ _id: id, a: 1 }, configuration.writeConcernMax(), function (err) { - // expect(err).to.not.exist; - // - // collection.insert({ _id: id, a: 1 }, configuration.writeConcernMax(), function (err) { - // test.ok(err !== null); - // running = false; - // p_client.close(done); - // }); - // }); - // }, 200); - // }); - // - // db.createCollection('collection2', function (err, collection) { - // // Keep hammering in inserts - // var insert; - // insert = function () { - // process.nextTick(function () { - // collection.insert({ a: 1 }); - // if (running) process.nextTick(insert); - // }); - // }; - // }); - // }); - // } - // }); - it('should correctly iterate over collection', async function () { const db = client.db(this.configuration.db); @@ -1033,52 +844,6 @@ describe('Find', function () { test.equal(2, docs[0].b); }); - // TODO(NODE-7219): Remove test as it duplicates "should perform a simple find with project fields" - // it('shouldPerformASimpleLimitSkipFindWithFields2', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // var configuration = this.configuration; - // var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // var db = client.db(configuration.db); - // - // // Create a collection we want to drop later - // db.createCollection('simple_find_with_fields_2', function (err, collection) { - // expect(err).to.not.exist; - // - // // Insert a bunch of documents for the testing - // collection.insert( - // [ - // { a: 1, b: 1 }, - // { a: 2, b: 2 }, - // { a: 3, b: 3 } - // ], - // configuration.writeConcernMax(), - // function (err) { - // expect(err).to.not.exist; - // - // // Perform a simple find and return all the documents - // collection - // .find({ a: 2 }) - // .project({ b: 1 }) - // .toArray(function (err, docs) { - // expect(err).to.not.exist; - // test.equal(1, docs.length); - // expect(docs[0].a).to.not.exist; - // test.equal(2, docs[0].b); - // - // client.close(done); - // }); - // } - // ); - // }); - // }); - // } - // }); - it('should perform query with batchSize different to standard', async function () { const configuration = this.configuration; const db = client.db(configuration.db); @@ -1099,140 +864,6 @@ describe('Find', function () { test.equal(1000, documents.length); }); - // TODO(NODE-7219): Remove test as it duplicates "should execute query using negative limit" - // it('shouldCorrectlyPerformNegativeLimit', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // - // // Create a collection we want to drop later - // const collection = db.collection('shouldCorrectlyPerformNegativeLimit'); - // const docs = []; - // for (const i = 0; i < 1000; i++) { - // docs.push({ - // a: 1, - // b: 'helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld' - // }); - // } - // - // // Insert a bunch of documents - // collection.insert(docs, configuration.writeConcernMax(), function (err) { - // expect(err).to.not.exist; - // - // // Perform a simple find and return all the documents - // collection - // .find({}) - // .limit(-10) - // .toArray(function (err, docs) { - // expect(err).to.not.exist; - // test.equal(10, docs.length); - // - // client.close(done); - // }); - // }); - // }); - // } - // }); - - // TODO(NODE-7219): Remove test as "exhaust" is deprecated - // it('shouldCorrectlyExecuteExhaustQuery', { - // metadata: { requires: { topology: ['single', 'replicaset'] } }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // - // // Create a collection we want to drop later - // db.createCollection('shouldCorrectlyExecuteExhaustQuery', function (err, collection) { - // expect(err).to.not.exist; - // - // const docs1 = []; - // for (const i = 0; i < 1000; i++) { - // docs1.push({ - // a: 1, - // b: 'helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld', - // c: new Binary(Buffer.alloc(1024)) - // }); - // } - // - // // Insert a bunch of documents - // collection.insert(docs1, configuration.writeConcernMax(), function (err) { - // expect(err).to.not.exist; - // - // for (const i = 0; i < 1000; i++) { - // const docs2 = []; - // docs2.push({ - // a: 1, - // b: 'helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld', - // c: new Binary(Buffer.alloc(1024)) - // }); - // } - // - // collection.insert(docs2, configuration.writeConcernMax(), function (err) { - // expect(err).to.not.exist; - // - // // Perform a simple find and return all the documents - // collection.find({}, { exhaust: true }).toArray(function (err, docs3) { - // expect(err).to.not.exist; - // test.equal(docs1.length + docs2.length, docs3.length); - // - // client.close(done); - // }); - // }); - // }); - // }); - // }); - // } - // }); - - // TODO(NODE-7219): Remove test as it duplicates "should respect client-level read preference" - // it('Readpreferences should work fine when using a single server instance', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // expect(err).to.not.exist; - // - // const docs = []; - // for (const i = 0; i < 1; i++) { - // docs.push({ - // a: 1, - // b: 'helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld' - // }); - // } - // - // // Create a collection we want to drop later - // db.createCollection('Readpreferencesshouldworkfine', function (err, collection) { - // // Insert a bunch of documents - // collection.insert(docs, configuration.writeConcernMax(), function (err) { - // expect(err).to.not.exist; - // // Perform a simple find and return all the documents - // collection.find({}, { exhaust: true }).toArray(function (err, docs2) { - // expect(err).to.not.exist; - // test.equal(docs.length, docs2.length); - // - // client.close(done); - // }); - // }); - // }); - // }); - // } - // }); - it('should correctly iterate over an empty cursor', async function () { const collection = client.db().collection('empty_collection_for_iteration'); let iteratedCount = 0; @@ -1262,52 +893,6 @@ describe('Find', function () { } }); - // TODO(NODE-7219): Remove test as it duplicates "should correctly perform find with options" - // it('shouldCorrectlyDoFindMinMax', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // // Serialized regexes contain extra trailing chars. Sometimes these trailing chars contain / which makes - // // the original regex invalid, and leads to segmentation fault. - // db.createCollection('shouldCorrectlyDoFindMinMax', function (err, collection) { - // collection.insert( - // { _id: 123, name: 'some name', min: 1, max: 10 }, - // configuration.writeConcernMax(), - // function (err) { - // expect(err).to.not.exist; - // - // collection - // .find({ _id: { $in: ['some', 'value', 123] } }) - // .project({ _id: 1, max: 1 }) - // .toArray(function (err, docs) { - // expect(err).to.not.exist; - // test.equal(10, docs[0].max); - // - // collection - // .find( - // { _id: { $in: ['some', 'value', 123] } }, - // { projection: { _id: 1, max: 1 } } - // ) - // .toArray(function (err, docs) { - // expect(err).to.not.exist; - // test.equal(10, docs[0].max); - // - // client.close(done); - // }); - // }); - // } - // ); - // }); - // }); - // } - // }); - it('should correctly sort using text search in find', async function () { const configuration = this.configuration; const db = client.db(configuration.db); @@ -1403,63 +988,6 @@ describe('Find', function () { test.deepEqual([{ _id: 1, results: [82, 85, 88] }], documents); }); - // TODO(NODE-7219): Remove test as it duplicates "should correctly perform find with limit" - // it('should execute query using limit of 101', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // var configuration = this.configuration; - // var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // var db = client.db(configuration.db); - // const collection = db.collection('test_find_simple_limit_101'); - // function clone(obj) { - // var o = {}; - // for (var name in obj) o[name] = obj[name]; - // return o; - // } - // - // var template = { - // linkid: '12633170', - // advertisercid: '4612127', - // websitename: 'Car Rental 8', - // destinationurl: 'https://www.carrental8.com/en/', - // who: '8027061-12633170-1467924618000', - // href: 'http://www.tkqlhce.com', - // src: 'http://www.awltovhc.com', - // r1: 3, - // r2: 44, - // r3: 24, - // r4: 58 - // }; - // - // var docs = []; - // for (var i = 0; i < 1000; i++) { - // docs.push(clone(template)); - // } - // - // // Insert some test documents - // collection.insertMany(docs, configuration.writeConcernMax(), function (err, r) { - // expect(err).to.not.exist; - // test.ok(r); - // - // // Ensure correct insertion testing via the cursor and the count function - // collection - // .find() - // .limit(200) - // .toArray(function (err, documents) { - // expect(err).to.not.exist; - // test.equal(200, documents.length); - // // Let's close the db - // client.close(done); - // }); - // }); - // }); - // } - // }); - it('should correctly apply db level options to find cursor', async function () { const configuration = this.configuration; const p_client = configuration.newClient({}, { ignoreUndefined: true }); diff --git a/test/integration/crud/insert.test.ts b/test/integration/crud/insert.test.ts index d491119e75..30b6f0feec 100644 --- a/test/integration/crud/insert.test.ts +++ b/test/integration/crud/insert.test.ts @@ -65,24 +65,6 @@ describe('crud - insert', function () { }); }); - // TODO(NODE-7219): remove as it duplicates "should correctly perform single insert" - // it('should correctly execute Collection.prototype.insertOne', async function () { - // const configuration = this.configuration; - // let url = configuration.url(); - // url = - // url.indexOf('?') !== -1 - // ? f('%s&%s', url, 'maxPoolSize=100') - // : f('%s?%s', url, 'maxPoolSize=100'); - // - // const client = configuration.newClient(url); - // await client.connect(); - // const db = client.db(configuration.db); - // - // const r = await db.collection('insertOne').insertOne({ a: 1 }); - // expect(r).property('insertedId').to.exist; - // await client.close(); - // }); - it('rejects when insertMany is passed a non array object', async function () { const db = client.db(); const error = await db @@ -381,44 +363,6 @@ describe('crud - insert', function () { test.equal(docs[0].field, '2'); }); - // TODO(NODE-7219): remove as it's outdated (no callbacks) - // it('shouldCorrectlyCallCallbackWithDbDriverInStrictMode', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('test_insert_and_update_no_callback_strict'); - // - // collection.insert( - // { _id: '12345678123456781234567812345678', field: '1' }, - // configuration.writeConcernMax(), - // function (err, result) { - // expect(err).to.not.exist; - // test.ok(result); - // - // collection.updateOne( - // { _id: '12345678123456781234567812345678' }, - // { $set: { field: 0 } }, - // configuration.writeConcernMax(), - // function (err, r) { - // expect(err).to.not.exist; - // expect(r).property('matchedCount').to.equal(1); - // client.close(done); - // } - // ); - // } - // ); - // }); - // } - // }); - it('should correctly insert DBRef with Db not defined', async function () { const configuration = this.configuration; const db = client.db(configuration.db); @@ -449,118 +393,6 @@ describe('crud - insert', function () { expect(items[2].ref.db).to.not.exist; }); - // TODO(NODE-7219): remove as it's redundant and combines many methods into one test - // it('shouldCorrectlyInsertUpdateRemoveWithNoOptions', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('shouldCorrectlyInsertUpdateRemoveWithNoOptions'); - // - // collection.insert({ a: 1 }, configuration.writeConcernMax(), function (err, result) { - // expect(err).to.not.exist; - // test.ok(result); - // - // collection.update( - // { a: 1 }, - // { $set: { a: 2 } }, - // configuration.writeConcernMax(), - // function (err, result) { - // expect(err).to.not.exist; - // test.ok(result); - // - // collection.deleteMany( - // { a: 2 }, - // configuration.writeConcernMax(), - // function (err, result) { - // expect(err).to.not.exist; - // test.ok(result); - // - // collection.count(function (err, count) { - // test.equal(0, count); - // client.close(done); - // }); - // } - // ); - // } - // ); - // }); - // }); - // } - // }); - - // TODO(NODE-7219): remove as it duplicates "simple insert" - // it('shouldCorrectlyExecuteMultipleFetches', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // // Search parameter - // const to = 'ralph'; - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('shouldCorrectlyExecuteMultipleFetches'); - // // Execute query - // collection.insert( - // { addresses: { localPart: 'ralph' } }, - // configuration.writeConcernMax(), - // function (err, result) { - // expect(err).to.not.exist; - // test.ok(result); - // - // // Let's find our user - // collection.findOne({ 'addresses.localPart': to }, function (err, doc) { - // expect(err).to.not.exist; - // test.equal(to, doc.addresses.localPart); - // client.close(done); - // }); - // } - // ); - // }); - // } - // }); - - // TODO(NODE-7219): remove as it duplicates "should not fail when update returning 0 results" - // it('shouldCorrectlyFailWhenNoObjectToUpdate', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('shouldCorrectlyFailWhenNoObjectToUpdate'); - // - // collection.update( - // { _id: new ObjectId() }, - // { $set: { email: 'update' } }, - // configuration.writeConcernMax(), - // function (err, result) { - // expect(err).to.not.exist; - // expect(result).property('matchedCount').to.equal(0); - // client.close(done); - // } - // ); - // }); - // } - // }); - it('should correctly insert object and retrieve it when containing array and IsoDate', async function () { const configuration = this.configuration; const doc = { @@ -737,39 +569,6 @@ describe('crud - insert', function () { expect(err).to.be.instanceOf(MongoServerError); }); - // TODO(7219): remove as it's redundant (custom ids are used in multiple other tests: "with UUID", "Date object as _id") - // it('shouldCorrectlyInsertDocWithCustomId', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('shouldCorrectlyInsertDocWithCustomId'); - // // Insert the update - // collection.insert( - // { _id: 0, test: 'hello' }, - // configuration.writeConcernMax(), - // function (err, result) { - // expect(err).to.not.exist; - // test.ok(result); - // - // collection.findOne({ _id: 0 }, function (err, item) { - // test.equal(0, item._id); - // test.equal('hello', item.test); - // client.close(done); - // }); - // } - // ); - // }); - // } - // }); - it('should correctly perform upsert against new document and existing one', async function () { const configuration = this.configuration; const db = client.db(configuration.db); @@ -825,245 +624,6 @@ describe('crud - insert', function () { test.deepEqual(1, result.c); }); - // TODO(NODE-7219): remove as it duplicates "should correctly perform large text insert" - // it('shouldAttempToForceBsonSize', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: 'single' } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // db.createCollection('shouldAttempToForceBsonSize', function (err, collection) { - // // var doc = {a:1, b:new Binary(Buffer.alloc(16777216)/5)} - // const doc = [ - // { a: 1, b: new Binary(Buffer.alloc(16777216 / 3)) }, - // { a: 1, b: new Binary(Buffer.alloc(16777216 / 3)) }, - // { a: 1, b: new Binary(Buffer.alloc(16777216 / 3)) } - // ]; - // - // collection.insert(doc, configuration.writeConcernMax(), function (err, result) { - // expect(err).to.not.exist; - // test.ok(result); - // - // collection.findOne({ a: 1 }, function (err, doc) { - // expect(err).to.not.exist; - // test.deepEqual(1, doc.a); - // - // client.close(done); - // }); - // }); - // }); - // }); - // } - // }); - - // TODO(NODE-7219): remove as it's irrelevant for insert functionality - // it('should correctly use custom object to update document', async function () { - // const configuration = this.configuration; - // const db = client.db(configuration.db); - // const collection = db.collection('shouldCorrectlyUseCustomObjectToUpdateDocument'); - // - // await collection.insertOne({ a: { b: { c: 1 } } }, configuration.writeConcernMax()); - // - // const query = { - // a: { b: { c: 1 } } - // }; - // - // // Update document - // const r = await collection.updateOne( - // query, - // { $set: { 'a.b.d': 1 } }, - // configuration.writeConcernMax() - // ); - // expect(r).property('matchedCount').to.equal(1); - // }); - - // TODO(NODE-7219): remove as it's outdated (no callbacks) - // it('shouldExecuteInsertWithNoCallbackAndWriteConcern', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('shouldExecuteInsertWithNoCallbackAndWriteConcern'); - // collection.insert({ a: { b: { c: 1 } } }).then( - // () => { - // client.close(done); - // }, - // err => { - // client.close(err2 => done(err || err2)); - // } - // ); - // }); - // } - // }); - - // TODO(NODE-7219): remove as it's outdated (no callbacks) - // it('executesCallbackOnceWithOveriddenDefaultDbWriteConcern', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // function cb(err) { - // expect(err).to.not.exist; - // client.close(done); - // } - // - // const configuration = this.configuration; - // var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('gh-completely2'); - // collection.insert({ a: 1 }, { writeConcern: { w: 0 } }, cb); - // }); - // } - // }); - - // TODO(NODE-7219): remove as it's outdated (no callbacks) - // it('executesCallbackOnceWithOveriddenDefaultDbWriteConcernWithUpdate', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // function cb(err) { - // expect(err).to.not.exist; - // client.close(done); - // } - // - // const configuration = this.configuration; - // var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('gh-completely3'); - // collection.update( - // { a: 1 }, - // { $set: { a: 2 } }, - // { upsert: true, writeConcern: { w: 0 } }, - // cb - // ); - // }); - // } - // }); - - // TODO(NODE-7219): remove as it's outdated (no callbacks) - // it('executesCallbackOnceWithOveriddenDefaultDbWriteConcernWithRemove', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // function cb(err) { - // expect(err).to.not.exist; - // client.close(done); - // } - // - // const configuration = this.configuration; - // var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('gh-completely1'); - // collection.deleteMany({ a: 1 }, { writeConcern: { w: 0 } }, cb); - // }); - // } - // }); - - // TODO(NODE-7219): remove as it duplicates "handles BSON type inserts" - // it('handleBSONTypeInsertsCorrectly', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { - // topology: ['single', 'replicaset', 'ssl', 'heap', 'wiredtiger'], - // mongodb: '<2.8.0' - // } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // const collection = db.collection('bson_types_insert'); - // - // const document = { - // symbol: new BSONSymbol('abcdefghijkl'), - // objid: new ObjectId('abcdefghijkl'), - // double: new Double(1), - // binary: new Binary(Buffer.from('hello world')), - // minkey: new MinKey(), - // maxkey: new MaxKey(), - // code: new Code('function () {}', { a: 55 }) - // }; - // - // collection.insert(document, configuration.writeConcernMax(), function (err, result) { - // expect(err).to.not.exist; - // test.ok(result); - // - // collection.findOne({ symbol: new BSONSymbol('abcdefghijkl') }, function (err, doc) { - // expect(err).to.not.exist; - // test.equal('abcdefghijkl', doc.symbol.toString()); - // - // collection.findOne({ objid: new ObjectId('abcdefghijkl') }, function (err, doc) { - // expect(err).to.not.exist; - // test.equal('6162636465666768696a6b6c', doc.objid.toString()); - // - // collection.findOne({ double: new Double(1) }, function (err, doc) { - // expect(err).to.not.exist; - // test.equal(1, doc.double); - // - // collection.findOne( - // { binary: new Binary(Buffer.from('hello world')) }, - // function (err, doc) { - // expect(err).to.not.exist; - // test.equal('hello world', doc.binary.toString()); - // - // collection.findOne({ minkey: new MinKey() }, function (err, doc) { - // expect(err).to.not.exist; - // test.ok(doc.minkey._bsontype === 'MinKey'); - // - // collection.findOne({ maxkey: new MaxKey() }, function (err, doc) { - // expect(err).to.not.exist; - // test.ok(doc.maxkey._bsontype === 'MaxKey'); - // - // collection.findOne( - // { code: new Code('function () {}', { a: 55 }) }, - // function (err, doc) { - // expect(err).to.not.exist; - // test.ok(doc != null); - // client.close(done); - // } - // ); - // }); - // }); - // } - // ); - // }); - // }); - // }); - // }); - // }); - // } - // }); - it('handles BSON type inserts', async function () { const configuration = this.configuration; @@ -1310,71 +870,6 @@ describe('crud - insert', function () { expect(doc.array[0][0]).to.be.a('number'); }); - // TODO(NODE-7219): remove as it duplicates "should correctly honor promoteLong:[true|false]" - // it('shouldCorrectlyHonorPromoteLongFalseJSBSON', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: async function () { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { - // maxPoolSize: 1, - // promoteLongs: false - // }); - // await client.connect(); - // const db = client.db(configuration.db); - // await db.collection('shouldCorrectlyHonorPromoteLongFalseJSBSON').insertOne({ - // doc: Long.fromNumber(10), - // array: [[Long.fromNumber(10)]] - // }); - // const doc = await db.collection('shouldCorrectlyHonorPromoteLongFalseJSBSON').findOne({}); - // expect(doc.doc._bsontype).to.equal('Long'); - // expect(doc.array[0][0]._bsontype).to.equal('Long'); - // - // await client.close(); - // } - // }); - - // TODO(NODE-7219): remove as it duplicates "should correctly honor promoteLong:true native BSON" - // it('shouldCorrectlyHonorPromoteLongTrueJSBSON', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // db.collection('shouldCorrectlyHonorPromoteLongTrueJSBSON').insert( - // { - // doc: Long.fromNumber(10), - // array: [[Long.fromNumber(10)]] - // }, - // function (err, doc) { - // expect(err).to.not.exist; - // test.ok(doc); - // - // db.collection('shouldCorrectlyHonorPromoteLongTrueJSBSON').findOne( - // function (err, doc) { - // expect(err).to.not.exist; - // expect(err).to.not.exist; - // test.ok('number', typeof doc.doc); - // test.ok('number', typeof doc.array[0][0]); - // client.close(done); - // } - // ); - // } - // ); - // }); - // } - // }); - it('should correctly work with checkKeys', async function () { const configuration = this.configuration; diff --git a/test/integration/crud/misc_cursors.test.ts b/test/integration/crud/misc_cursors.test.ts index 0044eca7d7..d1543b8755 100644 --- a/test/integration/crud/misc_cursors.test.ts +++ b/test/integration/crud/misc_cursors.test.ts @@ -770,7 +770,7 @@ describe('Cursor', function () { // for (let ii = 0; ii < 10; ++ii) docs.push({ b: ii + 1 }); // // insert all docs - // collection.insert(docs, configuration.writeConcernMax(), err => { + // collection.insertMany(docs, configuration.writeConcernMax(), err => { // expect(err).to.not.exist; // let finished = 0, diff --git a/test/integration/crud/server_errors.test.ts b/test/integration/crud/server_errors.test.ts index 29271f5f2c..3414dd1467 100644 --- a/test/integration/crud/server_errors.test.ts +++ b/test/integration/crud/server_errors.test.ts @@ -37,38 +37,6 @@ describe('Errors', function () { expect(err.code).to.equal(11000); }); - // TODO(NODE-7219): remove as it duplicates "should fail insert due to unique index" - // it('should fail insert due to unique index strict', function (done) { - // const db = client.db(this.configuration.db); - // db.dropCollection('test_failing_insert_due_to_unique_index_strict', () => { - // db.createCollection('test_failing_insert_due_to_unique_index_strict', err => { - // expect(err).to.not.exist; - // const collection = db.collection('test_failing_insert_due_to_unique_index_strict'); - // collection.createIndexes( - // [ - // { - // name: 'test_failing_insert_due_to_unique_index_strict', - // key: { a: 1 }, - // unique: true - // } - // ], - // { writeConcern: { w: 1 } }, - // err => { - // expect(err).to.not.exist; - // collection.insertOne({ a: 2 }, { writeConcern: { w: 1 } }, err => { - // expect(err).to.not.exist; - // - // collection.insertOne({ a: 2 }, { writeConcern: { w: 1 } }, err => { - // expect(err.code).to.equal(11000); - // done(); - // }); - // }); - // } - // ); - // }); - // }); - // }); - const PROJECTION_ERRORS = new Set([ 'Projection cannot have a mix of inclusion and exclusion.', 'Cannot do exclusion on field b in inclusion projection' diff --git a/test/integration/index_management.test.ts b/test/integration/index_management.test.ts index 014b52d650..c46abc7f8e 100644 --- a/test/integration/index_management.test.ts +++ b/test/integration/index_management.test.ts @@ -333,7 +333,7 @@ describe('Indexes', function () { beforeEach(async function () { collection = await db.createCollection('test_drop_indexes'); - await collection.insert({ a: 1 }); + await collection.insertOne({ a: 1 }); // Create an index on the collection await db.createIndex(collection.collectionName, 'a'); }); @@ -383,7 +383,7 @@ describe('Indexes', function () { beforeEach(async function () { collection = await db.createCollection('test_index_exists'); - await collection.insert({ a: 1 }); + await collection.insertOne({ a: 1 }); await db.createIndex(collection.collectionName, 'a'); await db.createIndex(collection.collectionName, ['c', 'd', 'e']); diff --git a/test/integration/node-specific/bson-options/promote_values.test.ts b/test/integration/node-specific/bson-options/promote_values.test.ts index f92c32d4aa..a114c39595 100644 --- a/test/integration/node-specific/bson-options/promote_values.test.ts +++ b/test/integration/node-specific/bson-options/promote_values.test.ts @@ -31,65 +31,6 @@ describe('Promote Values', function () { await client.close(); }); - // TODO(NODE-7192): remove as it duplicates "should correctly honor promoteValues when creating an instance using Db" - // it('should correctly honor promoteValues when creating an instance using MongoClient', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: async function () { - // const configuration = this.configuration; - // const client = configuration.newClient({}, { promoteValues: false }); - // await client.connect(); - // const db = client.db(configuration.db); - // - // await db.collection('shouldCorrectlyHonorPromoteValues').insertOne({ - // doc: Long.fromNumber(10), - // int: 10, - // double: 2.2222, - // array: [[Long.fromNumber(10)]] - // }); - // - // const doc = await db.collection('shouldCorrectlyHonorPromoteValues').findOne(); - // expect(Long.fromNumber(10)).deep.equals(doc.doc); - // expect(new Int32(10)).deep.equals(doc.int); - // expect(new Double(2.2222)).deep.equals(doc.double); - // - // await client.close(); - // } - // }); - - // TODO(NODE-7192): remove as it duplicates "should correctly honor promoteValues when creating an instance using Db" - // it('should correctly honor promoteValues at cursor level', { - // // Add a tag that our runner can trigger on - // // in this case we are setting that node needs to be higher than 0.10.X to run - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } - // }, - // - // test: async function () { - // const configuration = this.configuration; - // const client = configuration.newClient({}, { promoteValues: false }); - // await client.connect(); - // const db = client.db(configuration.db); - // await db.collection('shouldCorrectlyHonorPromoteValues').insertOne({ - // doc: Long.fromNumber(10), - // int: 10, - // double: 2.2222, - // array: [[Long.fromNumber(10)]] - // }); - // - // const doc = await db.collection('shouldCorrectlyHonorPromoteValues').find().next(); - // expect(doc.doc).to.deep.equal(Long.fromNumber(10)); - // expect(doc.int).to.deep.equal(new Int32(10)); - // expect(doc.double).to.deep.equal(new Double(2.2222)); - // - // await client.close(); - // } - // }); - it('should correctly honor promoteValues at cursor find level', async function () { const configuration = this.configuration; const client = configuration.newClient(); diff --git a/test/integration/node-specific/db.test.ts b/test/integration/node-specific/db.test.ts index 50f1cddd25..206d32c516 100644 --- a/test/integration/node-specific/db.test.ts +++ b/test/integration/node-specific/db.test.ts @@ -66,28 +66,6 @@ describe('Db', function () { await client.close(); }); - // TODO(NODE-7192): remove test as it doesn't test anything - // it.skip('shouldCorrectlyThrowWhenTryingToReOpenConnection', { - // metadata: { - // requires: { topology: ['single', 'replicaset', 'sharded'] } - // }, - // - // test: function (done) { - // var configuration = this.configuration; - // var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(err => { - // expect(err).to.not.exist; - // - // try { - // client.connect(function () {}); - // test.ok(false); - // } catch { - // client.close(done); - // } - // }); - // } - // }); - it('should not cut collection name when it is the same as the database', async function () { const configuration = this.configuration; const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); diff --git a/test/integration/node-specific/mongo_client.test.ts b/test/integration/node-specific/mongo_client.test.ts index 87889efa21..e1a40917d4 100644 --- a/test/integration/node-specific/mongo_client.test.ts +++ b/test/integration/node-specific/mongo_client.test.ts @@ -381,68 +381,6 @@ describe('class MongoClient', function () { await client.close(); }); - // TODO(NODE-7219): remove unnecessary test - // it('should open a new MongoClient connection', { - // metadata: { - // requires: { - // topology: ['single'] - // } - // }, - - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(); - // client.connect(function (err, mongoclient) { - // expect(err).to.not.exist; - - // mongoclient - // .db('integration_tests') - // .collection('new_mongo_client_collection') - // .insertOne({ a: 1 }, function (err, r) { - // expect(err).to.not.exist; - // expect(r).to.be.an('object'); - - // mongoclient.close(done); - // }); - // }); - // } - // }); - - // TODO(NODE-7219): remove unnecessary test - // it('should correctly connect with MongoClient `connect` using Promise', function () { - // const configuration = this.configuration; - // let url = configuration.url(); - // url = url.indexOf('?') !== -1 ? `${url}&maxPoolSize=100` : `${url}?maxPoolSize=100`; - - // const client = configuration.newClient(url); - // return client.connect().then(() => client.close()); - // }); - - // TODO(NODE-7219): remove unnecessary test - // it('should open a new MongoClient connection using promise', { - // metadata: { - // requires: { - // topology: ['single'] - // } - // }, - - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(); - // client.connect().then(function (mongoclient) { - // mongoclient - // .db('integration_tests') - // .collection('new_mongo_client_collection') - // .insertOne({ a: 1 }) - // .then(function (r) { - // expect(r).to.exist; - - // mongoclient.close(done); - // }); - // }); - // } - // }); - it('should be able to access a database named "constructor"', function () { const client = this.configuration.newClient(); let err; diff --git a/test/integration/server-selection/readpreference.test.ts b/test/integration/server-selection/readpreference.test.ts index 300bfca2a5..49658fc09d 100644 --- a/test/integration/server-selection/readpreference.test.ts +++ b/test/integration/server-selection/readpreference.test.ts @@ -21,198 +21,6 @@ describe('ReadPreference', function () { return setupDatabase(this.configuration); }); - it.skip('Should correctly apply collection level read Preference to count', { - metadata: { requires: { mongodb: '>=2.6.0', topology: ['single', 'ssl'] } }, - - test: function (done) { - const configuration = this.configuration; - const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - client.connect(function (err, client) { - const db = client.db(configuration.db); - expect(err).to.not.exist; - // Set read preference - const collection = db.collection('read_pref_1', { - readPreference: ReadPreference.SECONDARY_PREFERRED - }); - // Save checkout function - const command = client.topology.command; - // Set up our checker method - client.topology.command = function (...args) { - if (args[0] === 'integration_tests.$cmd') { - test.equal(ReadPreference.SECONDARY_PREFERRED, args[2].readPreference.mode); - } - - return command.apply(db.s.topology, args); - }; - - // Execute count - collection.count(function (err) { - expect(err).to.not.exist; - client.topology.command = command; - - client.close(done); - }); - }); - } - }).skipReason = - '[NODE-7219] There is no method `command` on Topology, this test is not effective.'; - - it.skip('Should correctly apply collection level read Preference to aggregate', { - metadata: { requires: { mongodb: '>=2.6.0', topology: ['single', 'ssl'] } }, - - test: function (done) { - const configuration = this.configuration; - const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - client.connect(function (err, client) { - const db = client.db(configuration.db); - expect(err).to.not.exist; - // Set read preference - const collection = db.collection('read_pref_1', { - readPreference: ReadPreference.SECONDARY_PREFERRED - }); - // Save checkout function - const command = client.topology.command; - // Set up our checker method - client.topology.command = function (...args) { - if (args[0] === 'integration_tests.$cmd') { - test.equal(ReadPreference.SECONDARY_PREFERRED, args[2].readPreference.mode); - } - - return command.apply(db.s.topology, args); - }; - - const cursor = collection.aggregate([ - { - $project: { - author: 1, - tags: 1 - } - }, - { $unwind: '$tags' }, - { - $group: { - _id: { tags: '$tags' }, - authors: { $addToSet: '$author' } - } - } - ]); - - cursor.toArray(function (err) { - expect(err).to.not.exist; - client.topology.command = command; - - client.close(done); - }); - }); - } - }).skipReason = - '[NODE-7219] There is no method `command` on Topology, this test is not effective.'; - - it.skip('Should correctly honor the readPreferences at DB and individual command level', { - metadata: { requires: { mongodb: '>=2.6.0', topology: ['single', 'ssl'] } }, - - test: function (done) { - const configuration = this.configuration; - const client = configuration.newClient( - { w: 1, readPreference: 'secondary' }, - { maxPoolSize: 1 } - ); - client.connect(function (err, client) { - const db = client.db(configuration.db); - // Save checkout function - const command = client.topology.command; - // Set up our checker method - client.topology.command = function (...args) { - if (args[0] === 'integration_tests.$cmd') { - test.equal(ReadPreference.SECONDARY, args[2].readPreference.mode); - } - - return command.apply(db.s.topology, args); - }; - - db.command({ dbStats: true }, function (err) { - expect(err).to.not.exist; - - client.topology.command = function (...args) { - if (args[0] === 'integration_tests.$cmd') { - test.equal(ReadPreference.SECONDARY_PREFERRED, args[2].readPreference.mode); - } - - return command.apply(db.s.topology, args); - }; - - db.command({ dbStats: true }, { readPreference: 'secondaryPreferred' }, function (err) { - expect(err).to.not.exist; - client.topology.command = command; - client.close(done); - }); - }); - }); - } - }).skipReason = - '[NODE-7219] There is no method `command` on Topology, this test is not effective.'; - - // TODO(NODE-7219): Remove test. Type safety is now enforced by TypeScript. - // it('Should correctly apply readPreferences specified as objects', { - // metadata: { requires: { mongodb: '>=2.6.0', topology: ['single', 'ssl'] } }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // expect(err).to.not.exist; - // // Create read preference object. - // const mySecondaryPreferred = { mode: 'secondaryPreferred', tags: [] }; - // db.command({ dbStats: true }, { readPreference: mySecondaryPreferred }, function (err) { - // expect(err).to.not.exist; - // client.close(done); - // }); - // }); - // } - // }); - - // TODO(NODE-7219): Remove test. Type safety is now enforced by TypeScript. - // it('Should correctly pass readPreferences specified as objects to cursors', { - // metadata: { requires: { mongodb: '>=2.6.0', topology: ['single', 'ssl'] } }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // expect(err).to.not.exist; - // // Create read preference object. - // const mySecondaryPreferred = { mode: 'secondaryPreferred', tags: [] }; - // db.listCollections({}, { readPreference: mySecondaryPreferred }).toArray(function (err) { - // expect(err).to.not.exist; - // client.close(done); - // }); - // }); - // } - // }); - - // TODO(NODE-7219): Remove test. Type safety is now enforced by TypeScript. - // it('Should correctly pass readPreferences specified as objects to collection methods', { - // metadata: { requires: { mongodb: '>=2.6.0', topology: ['single', 'ssl'] } }, - // - // test: function (done) { - // const configuration = this.configuration; - // const client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - // client.connect(function (err, client) { - // const db = client.db(configuration.db); - // expect(err).to.not.exist; - // // Create read preference object. - // const mySecondaryPreferred = { mode: 'secondaryPreferred', tags: [] }; - // const cursor = db.collection('test').find({}, { readPreference: mySecondaryPreferred }); - // cursor.toArray(function (err) { - // expect(err).to.not.exist; - // client.close(done); - // }); - // }); - // } - // }); - it('Should correctly pass readPreferences on the Collection to listIndexes', { metadata: { requires: { topology: ['single'] } }, diff --git a/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts b/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts index 9550b3dcef..c12f918d01 100644 --- a/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts +++ b/test/integration/server-selection/server_selection.prose.sharded_retryable_writes.test.ts @@ -150,7 +150,7 @@ describe('Server Selection Sharded Retryable Writes Prose tests', function () { await client .db('test') .collection('test') - .insert({ a: 1 }) + .insertOne({ a: 1 }) .catch(() => null); expect(commandFailedEvents[0].address).to.equal(commandSucceededEvents[0].address); }); diff --git a/test/mocha_mongodb.js b/test/mocha_mongodb.js index 9c32b0ea4c..afb7febd9f 100644 --- a/test/mocha_mongodb.js +++ b/test/mocha_mongodb.js @@ -11,8 +11,7 @@ module.exports = { 'test/tools/runner/chai_addons.ts', 'test/tools/runner/ee_checker.ts', 'test/tools/runner/hooks/configuration.ts', - 'test/tools/runner/hooks/leak_checker.ts', - 'test/tools/runner/hooks/legacy_crud_shims.ts' + 'test/tools/runner/hooks/leak_checker.ts' ], extension: ['js', 'ts'], ui: 'test/tools/runner/metadata_ui.js', diff --git a/test/tools/runner/hooks/legacy_crud_shims.ts b/test/tools/runner/hooks/legacy_crud_shims.ts deleted file mode 100644 index 5c4bfd8b3f..0000000000 --- a/test/tools/runner/hooks/legacy_crud_shims.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { expect } from 'chai'; - -import { Collection } from '../../../../src'; - -// Setup legacy shims for tests that use removed or changed APIs -const legacyUsageCounts = { - insert: 0, - update: 0 -}; - -const legacyUsageMaximums = { - insert: 340, - update: 25 -}; - -// @ts-expect-error: Method no longer exists on Collection -Collection.prototype.insert = function (docs, options) { - legacyUsageCounts.insert += 1; - options = options != null && typeof options === 'object' ? options : { ordered: false }; - - docs = Array.isArray(docs) ? docs : [docs]; - - return this.insertMany(docs, options); -}; - -// @ts-expect-error: Method no longer exists on Collection -Collection.prototype.update = function (filter, update, options) { - legacyUsageCounts.update += 1; - options = options != null && typeof options === 'object' ? options : {}; - - return this.updateMany(filter, update, options); -}; - -function assertLegacyAPIUsageDoesNotIncrease() { - expect( - legacyUsageCounts.insert, - 'Please do not use more instance of the legacy CRUD API: insert' - ).is.lessThanOrEqual(legacyUsageMaximums.insert); - expect( - legacyUsageCounts.update, - 'Please do not use more instance of the legacy CRUD API: update' - ).is.lessThanOrEqual(legacyUsageMaximums.update); -} - -export const mochaHooks = { - afterAll: [assertLegacyAPIUsageDoesNotIncrease] -};