Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed May 13, 2024
1 parent f498cc5 commit 3c74f46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/aggregate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ Aggregate.prototype.exec = async function exec() {
applyGlobalMaxTimeMS(this.options, model.db.options, model.base.options);
applyGlobalDiskUse(this.options, model.db.options, model.base.options);

const asyncLocalStorage = this.model?.db?.base.transactionAsyncLocalStorage?.getStore();
const asyncLocalStorage = this.model()?.db?.base.transactionAsyncLocalStorage?.getStore();
if (!this.options.hasOwnProperty('session') && asyncLocalStorage?.session != null) {
this.options.session = asyncLocalStorage.session;
}
Expand Down
8 changes: 4 additions & 4 deletions test/docs/transactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ describe('transactions', function() {
await Test.createCollection();
await Test.deleteMany({});

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

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

throw new Error('Oops!');
}),
Expand Down

0 comments on commit 3c74f46

Please sign in to comment.