|
1 | 1 | import { expect } from 'chai'; |
2 | 2 |
|
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'; |
12 | 8 | import { type FailCommandFailPoint } from '../../tools/utils'; |
13 | 9 |
|
14 | 10 | describe('Transactions', function () { |
@@ -55,18 +51,19 @@ describe('Transactions', function () { |
55 | 51 | metadata: { |
56 | 52 | requires: { topology: ['replicaset', 'sharded'] } |
57 | 53 | }, |
58 | | - test: function (done) { |
| 54 | + test: async function () { |
59 | 55 | function fnThatReturnsBadPromise() { |
60 | 56 | return Promise.reject(); |
61 | 57 | } |
62 | 58 |
|
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 | + // }); |
70 | 67 | } |
71 | 68 | }); |
72 | 69 |
|
|
0 commit comments