Skip to content

Commit 6c22c80

Browse files
committed
test: fix handshake tests
1 parent d230c44 commit 6c22c80

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

src/operations/operation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export abstract class ModernizedOperation<TResult> extends AbstractOperation<TRe
167167
* ```
168168
*/
169169
handleOk(response: InstanceType<typeof this.SERVER_COMMAND_RESPONSE_TYPE>): TResult {
170+
console.log(response);
170171
return response.toObject(this.bsonOptions) as TResult;
171172
}
172173

test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
getFAASEnv,
77
Int32,
88
LEGACY_HELLO_COMMAND,
9+
MongoDBResponse,
910
type MongoClient
1011
} from '../../mongodb';
1112
import { sleep } from '../../tools/utils';
@@ -239,19 +240,21 @@ describe('Client Metadata Update Prose Tests', function () {
239240
}
240241
);
241242

242-
sinon.stub(Connection.prototype, 'command').callsFake(async function (ns, cmd, options) {
243-
// @ts-expect-error: sinon will place wrappedMethod on the command method.
244-
const command = Connection.prototype.command.wrappedMethod.bind(this);
245-
246-
if (cmd.hello || cmd[LEGACY_HELLO_COMMAND]) {
247-
if (!initialClientMetadata) {
248-
initialClientMetadata = cmd.client;
249-
} else {
250-
updatedClientMetadata = cmd.client;
243+
sinon
244+
.stub(Connection.prototype, 'command')
245+
.callsFake(async function (ns, cmd, options, responseType) {
246+
// @ts-expect-error: sinon will place wrappedMethod on the command method.
247+
const command = Connection.prototype.command.wrappedMethod.bind(this);
248+
249+
if (cmd.hello || cmd[LEGACY_HELLO_COMMAND]) {
250+
if (!initialClientMetadata) {
251+
initialClientMetadata = cmd.client;
252+
} else {
253+
updatedClientMetadata = cmd.client;
254+
}
251255
}
252-
}
253-
return command(ns, cmd, options);
254-
});
256+
return command(ns, cmd, options, responseType);
257+
});
255258

256259
await client.db('test').command({ ping: 1 });
257260
await sleep(5);
@@ -311,19 +314,21 @@ describe('Client Metadata Update Prose Tests', function () {
311314
client = this.configuration.newClient({}, { maxIdleTimeMS: 1 });
312315
client.appendMetadata({ name: 'library', version: '1.2', platform: 'Library Platform' });
313316

314-
sinon.stub(Connection.prototype, 'command').callsFake(async function (ns, cmd, options) {
315-
// @ts-expect-error: sinon will place wrappedMethod on the command method.
316-
const command = Connection.prototype.command.wrappedMethod.bind(this);
317-
318-
if (cmd.hello || cmd[LEGACY_HELLO_COMMAND]) {
319-
if (!initialClientMetadata) {
320-
initialClientMetadata = cmd.client;
321-
} else {
322-
updatedClientMetadata = cmd.client;
317+
sinon
318+
.stub(Connection.prototype, 'command')
319+
.callsFake(async function (ns, cmd, options, responseType) {
320+
// @ts-expect-error: sinon will place wrappedMethod on the command method.
321+
const command = Connection.prototype.command.wrappedMethod.bind(this);
322+
323+
if (cmd.hello || cmd[LEGACY_HELLO_COMMAND]) {
324+
if (!initialClientMetadata) {
325+
initialClientMetadata = cmd.client;
326+
} else {
327+
updatedClientMetadata = cmd.client;
328+
}
323329
}
324-
}
325-
return command(ns, cmd, options);
326-
});
330+
return command(ns, cmd, options, responseType);
331+
});
327332

328333
await client.db('test').command({ ping: 1 });
329334
await sleep(5);

0 commit comments

Comments
 (0)