Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/integration/transactions/transactions.prose.test.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
26 changes: 9 additions & 17 deletions test/integration/transactions/transactions.test.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down Expand Up @@ -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();
}
});

Expand Down