Skip to content

Commit fdda9b3

Browse files
committed
✨ Add mongo driver version 7
1 parent 02fbf78 commit fdda9b3

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
- 5.0
2929
- 6.0
3030
- 7.0
31+
- 8.0
3132
services:
3233
mongodb:
3334
image: mongo:${{ matrix.mongodb }}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "MongoDB database adapter for ShareDB",
55
"main": "index.js",
66
"dependencies": {
7-
"mongodb": "^3.1.13 || ^4.0.0 || ^5.0.0 || ^6.0.0",
7+
"mongodb": "^3.1.13 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
88
"sharedb": "^1.9.1 || ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
99
},
1010
"devDependencies": {
@@ -18,6 +18,7 @@
1818
"mongodb4": "npm:mongodb@^4.0.0",
1919
"mongodb5": "npm:mongodb@^5.0.0",
2020
"mongodb6": "npm:mongodb@^6.0.0",
21+
"mongodb7": "npm:mongodb@^7.0.0",
2122
"nyc": "^14.1.1",
2223
"ot-json1": "^1.0.1",
2324
"rich-text": "^4.1.0",
@@ -33,7 +34,8 @@
3334
"test:mongodb4": "_SHAREDB_MONGODB_DRIVER=mongodb4 npm test",
3435
"test:mongodb5": "_SHAREDB_MONGODB_DRIVER=mongodb5 npm test",
3536
"test:mongodb6": "_SHAREDB_MONGODB_DRIVER=mongodb6 npm test",
36-
"test:all": "npm run test:mongodb3 && npm run test:mongodb4 && npm run test:mongodb5 && npm run test:mongodb6",
37+
"test:mongodb7": "_SHAREDB_MONGODB_DRIVER=mongodb7 npm test",
38+
"test:all": "npm run test:mongodb3 && npm run test:mongodb4 && npm run test:mongodb5 && npm run test:mongodb6 && npm run test:mongodb7",
3739
"test-cover": "nyc --temp-dir=coverage -r text -r lcov npm run test:all"
3840
},
3941
"repository": "git://github.com/share/sharedb-mongo.git",

test/test_mongo_middleware.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ describe('mongo db middleware', function() {
7171

7272
describe(BEFORE_EDIT, function() {
7373
it('has the expected properties on the request object', function(done) {
74+
var middlewareEntranceCount = 0;
75+
7476
db.use(BEFORE_EDIT, function(request, next) {
77+
middlewareEntranceCount = middlewareEntranceCount + 1;
7578
expect(request).to.have.all.keys([
7679
'action',
7780
'collectionName',
@@ -87,7 +90,6 @@ describe('mongo db middleware', function() {
8790
expect(request.options.testOptions).to.equal('yes');
8891
expect(request.query._id).to.equal('test1');
8992
next();
90-
done();
9193
});
9294

9395
var snapshot = {type: 'json0', id: 'test1', v: 1, data: {foo: 'bar'}};
@@ -98,6 +100,9 @@ describe('mongo db middleware', function() {
98100
if (err) return done(err);
99101
db.commit('testcollection', snapshot.id, editOp, newSnapshot, {testOptions: 'yes'}, function(err) {
100102
if (err) return done(err);
103+
104+
expect(middlewareEntranceCount).to.equal(1);
105+
done();
101106
});
102107
});
103108
});
@@ -221,7 +226,10 @@ describe('mongo db middleware', function() {
221226

222227
describe(BEFORE_SNAPSHOT_LOOKUP, function() {
223228
it('has the expected properties on the request object before getting a single snapshot', function(done) {
229+
var middlewareEntranceCount = 0;
230+
224231
db.use(BEFORE_SNAPSHOT_LOOKUP, function(request, next) {
232+
middlewareEntranceCount = middlewareEntranceCount + 1;
225233
expect(request).to.have.all.keys([
226234
'action',
227235
'collectionName',
@@ -233,7 +241,6 @@ describe('mongo db middleware', function() {
233241
expect(request.options.testOptions).to.equal('yes');
234242
expect(request.query._id).to.equal('test1');
235243
next();
236-
done();
237244
});
238245

239246
var snapshot = {type: 'json0', id: 'test1', v: 1, data: {foo: 'bar'}};
@@ -242,6 +249,8 @@ describe('mongo db middleware', function() {
242249
db.getSnapshot('testcollection', 'test1', null, {testOptions: 'yes'}, function(err, doc) {
243250
if (err) return done(err);
244251
expect(doc).to.exist;
252+
expect(middlewareEntranceCount).to.equal(1);
253+
done();
245254
});
246255
});
247256
});
@@ -356,7 +365,9 @@ describe('mongo db middleware', function() {
356365
});
357366

358367
it('has the expected properties on the request object before getting bulk snapshots', function(done) {
368+
var middlewareEntranceCount = 0;
359369
db.use(BEFORE_SNAPSHOT_LOOKUP, function(request, next) {
370+
middlewareEntranceCount = middlewareEntranceCount + 1;
360371
expect(request).to.have.all.keys([
361372
'action',
362373
'collectionName',
@@ -368,7 +379,6 @@ describe('mongo db middleware', function() {
368379
expect(request.options.testOptions).to.equal('yes');
369380
expect(request.query._id).to.deep.equal({$in: ['test1']});
370381
next();
371-
done();
372382
});
373383

374384
var snapshot = {type: 'json0', id: 'test1', v: 1, data: {foo: 'bar'}};
@@ -377,6 +387,8 @@ describe('mongo db middleware', function() {
377387
db.getSnapshotBulk('testcollection', ['test1'], null, {testOptions: 'yes'}, function(err, doc) {
378388
if (err) return done(err);
379389
expect(doc).to.exist;
390+
expect(middlewareEntranceCount).to.equal(1);
391+
done();
380392
});
381393
});
382394
});

0 commit comments

Comments
 (0)