Skip to content

Commit 77f4343

Browse files
test(NODE-7182): migrate integration/connection-monitoring-and-pooling tests (#4675)
Co-authored-by: Bailey Pearson <bailey.pearson@mongodb.com>
1 parent 2a47bbb commit 77f4343

File tree

1 file changed

+21
-29
lines changed

1 file changed

+21
-29
lines changed

test/integration/connection-monitoring-and-pooling/connection.test.ts

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1+
import { type EventEmitter, once } from 'node:events';
2+
import { setTimeout } from 'node:timers';
3+
14
import { expect } from 'chai';
2-
import { type EventEmitter, once } from 'events';
35
import * as sinon from 'sinon';
4-
import { setTimeout } from 'timers';
56

67
import {
7-
addContainerMetadata,
88
Binary,
9-
connect,
10-
Connection,
119
type ConnectionOptions,
12-
HostAddress,
13-
LEGACY_HELLO_COMMAND,
14-
makeClientMetadata,
1510
MongoClient,
1611
MongoClientAuthProviders,
1712
type MongoClientOptions,
18-
MongoDBResponse,
1913
MongoServerError,
20-
ns,
21-
ServerHeartbeatStartedEvent,
22-
Topology
23-
} from '../../mongodb';
14+
ServerHeartbeatStartedEvent
15+
} from '../../../src';
16+
import { connect } from '../../../src/cmap/connect';
17+
import { Connection } from '../../../src/cmap/connection';
18+
import {
19+
addContainerMetadata,
20+
makeClientMetadata
21+
} from '../../../src/cmap/handshake/client_metadata';
22+
import { MongoDBResponse } from '../../../src/cmap/wire_protocol/responses';
23+
import { LEGACY_HELLO_COMMAND } from '../../../src/constants';
24+
import { Topology } from '../../../src/sdam/topology';
25+
import { HostAddress, ns } from '../../../src/utils';
2426
import * as mock from '../../tools/mongodb-mock/index';
2527
import { processTick, sleep } from '../../tools/utils';
2628
import { assert as test, setupDatabase } from '../shared';
@@ -173,7 +175,7 @@ describe('Connection', function () {
173175
metadata: {
174176
requires: { topology: 'single', os: '!win32' }
175177
},
176-
test: function (done) {
178+
test: async function () {
177179
const configuration = this.configuration;
178180
const uri = `mongodb://${encodeURIComponent('/tmp/mongodb-27017.sock')}?w=1`;
179181
const options: MongoClientOptions = {
@@ -186,22 +188,12 @@ describe('Connection', function () {
186188

187189
const db = client.db(configuration.db);
188190

189-
db.collection('domainSocketCollection0').insert(
190-
{ a: 1 },
191-
{ writeConcern: { w: 1 } },
192-
function (err) {
193-
expect(err).to.not.exist;
194-
195-
db.collection('domainSocketCollection0')
196-
.find({ a: 1 })
197-
.toArray(function (err, items) {
198-
expect(err).to.not.exist;
199-
test.equal(1, items.length);
191+
await db
192+
.collection('domainSocketCollection0')
193+
.insertOne({ a: 1 }, { writeConcern: { w: 1 } });
200194

201-
done();
202-
});
203-
}
204-
);
195+
const items = await db.collection('domainSocketCollection0').find({ a: 1 }).toArray();
196+
test.equal(1, items.length);
205197
}
206198
});
207199

0 commit comments

Comments
 (0)