Skip to content

Commit 01ee2f1

Browse files
committed
test(NODE-7187): Migrate test/integration/transactions tests
1 parent 36609b1 commit 01ee2f1

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

test/integration/transactions/transactions.prose.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { type ObjectId } from 'bson';
12
import { expect } from 'chai';
23

3-
import { type MongoClient, type ObjectId } from '../../mongodb';
4+
import { type MongoClient } from '../../../src/mongo_client';
45

56
const metadata: MongoDBMetadataUI = {
67
requires: {

test/integration/transactions/transactions.test.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import { expect } from 'chai';
22

3-
import {
4-
ClientSession,
5-
type Collection,
6-
type CommandStartedEvent,
7-
type MongoClient,
8-
MongoInvalidArgumentError,
9-
MongoNetworkError,
10-
type ServerSessionPool
11-
} from '../../mongodb';
3+
import { type CommandStartedEvent } from '../../../src/cmap/command_monitoring_events';
4+
import { type Collection } from '../../../src/collection';
5+
import { MongoInvalidArgumentError, MongoNetworkError } from '../../../src/error';
6+
import { type MongoClient } from '../../../src/mongo_client';
7+
import { ClientSession, type ServerSessionPool } from '../../../src/sessions';
128
import { type FailCommandFailPoint } from '../../tools/utils';
139

1410
describe('Transactions', function () {
@@ -55,18 +51,19 @@ describe('Transactions', function () {
5551
metadata: {
5652
requires: { topology: ['replicaset', 'sharded'] }
5753
},
58-
test: function (done) {
54+
test: async function () {
5955
function fnThatReturnsBadPromise() {
6056
return Promise.reject();
6157
}
6258

63-
session
64-
.withTransaction(fnThatReturnsBadPromise)
65-
.then(() => done(Error('Expected error')))
66-
.catch(err => {
67-
expect(err).to.equal(undefined);
68-
session.endSession(done);
69-
});
59+
const err = await session.withTransaction(fnThatReturnsBadPromise).catch(err => err);
60+
expect(err).to.equal(undefined);
61+
await session.endSession();
62+
// .then(() => done(Error('Expected error')))
63+
// .catch(err => {
64+
// expect(err).to.equal(undefined);
65+
// session.endSession(done);
66+
// });
7067
}
7168
});
7269

0 commit comments

Comments
 (0)