Skip to content

Commit 24c17d7

Browse files
committed
migrate
1 parent 36609b1 commit 24c17d7

File tree

1 file changed

+26
-38
lines changed

1 file changed

+26
-38
lines changed

test/integration/uri-options/uri.test.js

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { expect } = require('chai');
44
const sinon = require('sinon');
5-
const { Topology } = require('../../mongodb');
5+
const { Topology } = require('../../../src/sdam/topology');
66

77
describe('URI', function () {
88
let client;
@@ -20,7 +20,7 @@ describe('URI', function () {
2020
// in this case we are setting that node needs to be higher than 0.10.X to run
2121
metadata: { requires: { topology: 'single' } },
2222

23-
test: function (done) {
23+
test: async function () {
2424
var self = this;
2525

2626
const authInformation = process.env.AUTH === 'auth' ? 'bob:pwd123@' : '';
@@ -29,22 +29,16 @@ describe('URI', function () {
2929
`mongodb://${authInformation}localhost:27017/?w=0`
3030
);
3131

32-
client.connect(function (err, client) {
33-
expect(err).to.not.exist;
34-
var db = client.db(self.configuration.db);
35-
36-
db.collection('mongoclient_test').update(
37-
{ a: 1 },
38-
{ $set: { b: 1 } },
39-
{ upsert: true },
40-
function (err, result) {
41-
expect(err).to.not.exist;
42-
expect(result).to.exist;
43-
expect(result).property('acknowledged').to.be.false;
44-
client.close(done);
45-
}
46-
);
47-
});
32+
await client.connect();
33+
var db = client.db(self.configuration.db);
34+
35+
const result = await db
36+
.collection('mongoclient_test')
37+
.update({ a: 1 }, { $set: { b: 1 } }, { upsert: true });
38+
39+
expect(result).to.exist;
40+
expect(result).property('acknowledged').to.be.false;
41+
await client.close();
4842
}
4943
});
5044

@@ -53,17 +47,14 @@ describe('URI', function () {
5347
// in this case we are setting that node needs to be higher than 0.10.X to run
5448
metadata: { requires: { topology: 'single' } },
5549

56-
test: function (done) {
50+
test: async function () {
5751
if (process.platform === 'win32') {
58-
return done();
52+
return;
5953
}
6054

6155
const client = this.configuration.newClient('mongodb://%2Ftmp%2Fmongodb-27017.sock');
62-
63-
client.connect(function (err, client) {
64-
expect(err).to.not.exist;
65-
client.close(done);
66-
});
56+
await client.connect();
57+
await client.close();
6758
}
6859
});
6960

@@ -72,13 +63,12 @@ describe('URI', function () {
7263
// in this case we are setting that node needs to be higher than 0.10.X to run
7364
metadata: { requires: { topology: 'single' } },
7465

75-
test: function (done) {
66+
test: async function () {
7667
const client = this.configuration.newClient('mongodb://127.0.0.1:27017/?fsync=true');
77-
client.connect((err, client) => {
78-
var db = client.db(this.configuration.db);
79-
expect(db.writeConcern.journal).to.be.true;
80-
client.close(done);
81-
});
68+
await client.connect();
69+
var db = client.db(this.configuration.db);
70+
expect(db.writeConcern.journal).to.be.true;
71+
await client.close();
8272
}
8373
});
8474

@@ -114,17 +104,15 @@ describe('URI', function () {
114104

115105
it('should correctly translate uri options', {
116106
metadata: { requires: { topology: 'replicaset' } },
117-
test: function (done) {
107+
test: async function () {
118108
const config = this.configuration;
119109
const uri = `mongodb://${config.host}:${config.port}/${config.db}?replicaSet=${config.replicasetName}`;
120110

121111
const client = this.configuration.newClient(uri);
122-
client.connect((err, client) => {
123-
expect(err).to.not.exist;
124-
expect(client).to.exist;
125-
expect(client.options.replicaSet).to.exist.and.equal(config.replicasetName);
126-
client.close(done);
127-
});
112+
await client.connect();
113+
expect(client).to.exist;
114+
expect(client.options.replicaSet).to.exist.and.equal(config.replicasetName);
115+
await client.close();
128116
}
129117
});
130118

0 commit comments

Comments
 (0)