Skip to content

Commit ab2f100

Browse files
committed
fix: tests
1 parent 10f9a4a commit ab2f100

File tree

2 files changed

+14
-45
lines changed

2 files changed

+14
-45
lines changed

test/integration/crud/remove.test.js

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -103,50 +103,19 @@ describe('Remove', function () {
103103
}
104104
});
105105

106-
it('should correctly remove only first document', {
107-
metadata: {
108-
requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] }
109-
},
110-
111-
test: function (done) {
112-
const self = this;
113-
const client = self.configuration.newClient(self.configuration.writeConcernMax(), {
114-
maxPoolSize: 1
115-
});
116-
117-
client.connect(function (err, client) {
118-
const db = client.db(self.configuration.db);
119-
expect(err).to.not.exist;
120-
121-
db.createCollection('shouldCorrectlyRemoveOnlyFirstDocument', function (err) {
122-
expect(err).to.not.exist;
123-
124-
const collection = db.collection('shouldCorrectlyRemoveOnlyFirstDocument');
125-
126-
collection.insert(
127-
[{ a: 1 }, { a: 1 }, { a: 1 }, { a: 1 }],
128-
{ writeConcern: { w: 1 } },
129-
function (err) {
130-
expect(err).to.not.exist;
131-
132-
// Remove the first
133-
collection.deleteMany(
134-
{ a: 1 },
135-
{ writeConcern: { w: 1 }, single: true },
136-
function (err, r) {
137-
expect(r).property('deletedCount').to.equal(1);
138-
139-
collection.find({ a: 1 }).count(function (err, result) {
140-
expect(result).to.equal(3);
141-
client.close(done);
142-
});
143-
}
144-
);
145-
}
146-
);
147-
});
148-
});
149-
}
106+
it('deleteOne', async () => {
107+
const collection = client.db().collection('test');
108+
await collection.drop().catch(() => null);
109+
await collection.insertMany([
110+
{ a: 1, i: 0 },
111+
{ a: 1, i: 1 },
112+
{ a: 1, i: 2 }
113+
]);
114+
const delRes = await collection.deleteOne({ a: 1 });
115+
expect(delRes).property('deletedCount', 1);
116+
const docs = await collection.find().toArray();
117+
expect(docs).to.have.lengthOf(2);
118+
expect(docs.map(({ i }) => i)).to.deep.equal([1, 2]);
150119
});
151120

152121
it('should not error on empty remove', {

test/tools/runner/hooks/legacy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const legacyUsageCounts = {
99
};
1010

1111
const legacyUsageMaximums = {
12-
insert: 326,
12+
insert: 340,
1313
update: 19
1414
};
1515

0 commit comments

Comments
 (0)