Skip to content

Commit

Permalink
Merge pull request #11549 from Hashen110/async-code-and-promises
Browse files Browse the repository at this point in the history
fix: missing await for an async function call
  • Loading branch information
AbdelrahmanHafez committed Mar 21, 2022
2 parents 4544723 + 886cdd7 commit 25594ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/statics/statics.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function run() {
const result = await Person.findPersonByName('bill');

console.log(result);
cleanup();
await cleanup();
}

async function cleanup() {
Expand Down
14 changes: 7 additions & 7 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,9 @@ describe('mongoose module:', function() {

const movie = await Movie.create({ name: 'The Empire Strikes Back' });
await Person.create({ name: 'Test1', favoriteMovie: movie._id });
assert.rejects(async() => {
await Person.findOne().populate({ path: 'favoriteGame' });
}, { message: 'Cannot populate path `favoriteGame` because it is not in your schema. Set the `strictPopulate` option to false to override.' });
await assert.rejects(async () => {
await Person.findOne().populate({path: 'favoriteGame'});
}, {message: 'Cannot populate path `favoriteGame` because it is not in your schema. Set the `strictPopulate` option to false to override.'});
});
it('allows global `strictPopulate` to be overriden on specific queries set to true (gh-10694)', async function() {
const mongoose = new Mongoose();
Expand All @@ -788,9 +788,9 @@ describe('mongoose module:', function() {
}));
const movie = await Movie.create({ name: 'The Empire Strikes Back' });
await Person.create({ name: 'Test1', favoriteMovie: movie._id });
assert.rejects(async() => {
await Person.findOne().populate({ path: 'favoriteGame', strictPopulate: true });
}, { message: 'Cannot populate path `favoriteGame` because it is not in your schema. Set the `strictPopulate` option to false to override.' });
await assert.rejects(async () => {
await Person.findOne().populate({path: 'favoriteGame', strictPopulate: true});
}, {message: 'Cannot populate path `favoriteGame` because it is not in your schema. Set the `strictPopulate` option to false to override.'});
});
it('allows global `strictPopulate` to be overriden on specific queries set to false (gh-10694)', async function() {
const mongoose = new Mongoose();
Expand Down Expand Up @@ -912,4 +912,4 @@ describe('mongoose module:', function() {
assert.deepEqual(await m.syncIndexes(), {});
});
});
});
});

0 comments on commit 25594ad

Please sign in to comment.