Skip to content

Commit 3c74f46

Browse files
committed
fix tests
1 parent f498cc5 commit 3c74f46

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/aggregate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ Aggregate.prototype.exec = async function exec() {
10221022
applyGlobalMaxTimeMS(this.options, model.db.options, model.base.options);
10231023
applyGlobalDiskUse(this.options, model.db.options, model.base.options);
10241024

1025-
const asyncLocalStorage = this.model?.db?.base.transactionAsyncLocalStorage?.getStore();
1025+
const asyncLocalStorage = this.model()?.db?.base.transactionAsyncLocalStorage?.getStore();
10261026
if (!this.options.hasOwnProperty('session') && asyncLocalStorage?.session != null) {
10271027
this.options.session = asyncLocalStorage.session;
10281028
}

test/docs/transactions.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ describe('transactions', function() {
370370
await Test.createCollection();
371371
await Test.deleteMany({});
372372

373-
const doc = new Test({ name: 'test' });
373+
const doc = new Test({ name: 'test_transactionAsyncLocalStorage' });
374374
await assert.rejects(
375375
() => m.connection.transaction(async() => {
376376
await doc.save();
@@ -383,10 +383,10 @@ describe('transactions', function() {
383383
docs = await Test.find({ _id: doc._id });
384384
assert.equal(docs.length, 1);
385385

386-
docs = await Promise.all([async() => {
386+
docs = await async function test() {
387387
return await Test.findOne({ _id: doc._id });
388-
}]).then(res => res[0]);
389-
assert.equal(docs.length, 1);
388+
}();
389+
assert.equal(doc.name, 'test_transactionAsyncLocalStorage');
390390

391391
throw new Error('Oops!');
392392
}),

0 commit comments

Comments
 (0)