diff --git a/test/integration/transactions/transactions.prose.test.ts b/test/integration/transactions/transactions.prose.test.ts index fa4c57bf013..79faf077c7b 100644 --- a/test/integration/transactions/transactions.prose.test.ts +++ b/test/integration/transactions/transactions.prose.test.ts @@ -1,6 +1,7 @@ +import { type ObjectId } from 'bson'; import { expect } from 'chai'; -import { type MongoClient, type ObjectId } from '../../mongodb'; +import { type MongoClient } from '../../../src/mongo_client'; const metadata: MongoDBMetadataUI = { requires: { diff --git a/test/integration/transactions/transactions.test.ts b/test/integration/transactions/transactions.test.ts index 2b84bc2e259..acd4579e371 100644 --- a/test/integration/transactions/transactions.test.ts +++ b/test/integration/transactions/transactions.test.ts @@ -1,14 +1,10 @@ import { expect } from 'chai'; -import { - ClientSession, - type Collection, - type CommandStartedEvent, - type MongoClient, - MongoInvalidArgumentError, - MongoNetworkError, - type ServerSessionPool -} from '../../mongodb'; +import { type CommandStartedEvent } from '../../../src/cmap/command_monitoring_events'; +import { type Collection } from '../../../src/collection'; +import { MongoInvalidArgumentError, MongoNetworkError } from '../../../src/error'; +import { type MongoClient } from '../../../src/mongo_client'; +import { ClientSession, type ServerSessionPool } from '../../../src/sessions'; import { type FailCommandFailPoint } from '../../tools/utils'; describe('Transactions', function () { @@ -55,18 +51,14 @@ describe('Transactions', function () { metadata: { requires: { topology: ['replicaset', 'sharded'] } }, - test: function (done) { + test: async function () { function fnThatReturnsBadPromise() { return Promise.reject(); } - session - .withTransaction(fnThatReturnsBadPromise) - .then(() => done(Error('Expected error'))) - .catch(err => { - expect(err).to.equal(undefined); - session.endSession(done); - }); + const err = await session.withTransaction(fnThatReturnsBadPromise).catch(err => err); + expect(err).to.equal(undefined); + await session.endSession(); } }); @@ -179,23 +171,21 @@ describe('Transactions', function () { describe('startTransaction', function () { it('should not error if transactions are supported', { metadata: { requires: { topology: ['sharded'] } }, - test: function (done) { + test: async function () { const configuration = this.configuration; const client = configuration.newClient(configuration.url()); - client.connect(err => { - expect(err).to.not.exist; + await client.connect(); - const session = client.startSession(); - const db = client.db(configuration.db); - const coll = db.collection('transaction_error_test'); - coll.insertOne({ a: 1 }, err => { - expect(err).to.not.exist; - expect(() => session.startTransaction()).to.not.throw(); + const session = client.startSession(); + const db = client.db(configuration.db); + const coll = db.collection('transaction_error_test'); + await coll.insertOne({ a: 1 }); + session.startTransaction(); - session.abortTransaction(() => session.endSession(() => client.close(done))); - }); - }); + await session.abortTransaction(); + await session.endSession(); + await client.close(); } }); });