-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test(NODE-7195): migrate integration/crud/find
tests
#4725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
it.skip('should correctly iterate over collection', async function () { | ||
const db = client.db(this.configuration.db); | ||
|
||
const collection = db.collection('shouldCorrectlyIterateOverCollection'); | ||
// Insert 500 documents | ||
const docsToInsert = Array.from({ length: 500 }, () => ({ | ||
a: 1, | ||
b: 2, | ||
c: { d: 3, f: 'sfdsffffffffffffffffffffffffffffff' } | ||
})); | ||
await collection.insertMany(docsToInsert); | ||
|
||
let iteratedCount = 0; | ||
const cursor = collection.find({}); | ||
|
||
for await (const doc of cursor) { | ||
expect(doc).to.exist; | ||
iteratedCount++; | ||
} | ||
|
||
expect(iteratedCount).to.equal(500); | ||
}).skipReason = 'TODO(NODE-3819): flaky tests (on macOS)'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though the test is skipped I took an opportunity to refactor it as well, maybe we can unskip it now as most probably it won't be flaky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with giving it a try; go for it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small comments. What a large PR!
}); | ||
}); | ||
it('should correctly perform find by $where', { | ||
metadata: { requires: { mongodb: '4.2.x' } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4.2 is our lowest tested server version - suggest removing metadata entirely
test/integration/crud/find.test.ts
Outdated
}); | ||
}); | ||
}); | ||
it('should execute query using limit of 101', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('should execute query using limit of 101', async function () { | |
it('should execute query using limit of 200', async function () { |
we may as well align the title with the test 🤷
}); | ||
}); | ||
} | ||
it('Should correctly apply db level options to find cursor', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest either removing this, or fixing it. as it is written, the test always passes (insert two docs, fetch all docs, assert two docs fetched)
it.skip('should correctly iterate over collection', async function () { | ||
const db = client.db(this.configuration.db); | ||
|
||
const collection = db.collection('shouldCorrectlyIterateOverCollection'); | ||
// Insert 500 documents | ||
const docsToInsert = Array.from({ length: 500 }, () => ({ | ||
a: 1, | ||
b: 2, | ||
c: { d: 3, f: 'sfdsffffffffffffffffffffffffffffff' } | ||
})); | ||
await collection.insertMany(docsToInsert); | ||
|
||
let iteratedCount = 0; | ||
const cursor = collection.find({}); | ||
|
||
for await (const doc of cursor) { | ||
expect(doc).to.exist; | ||
iteratedCount++; | ||
} | ||
|
||
expect(iteratedCount).to.equal(500); | ||
}).skipReason = 'TODO(NODE-3819): flaky tests (on macOS)'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with giving it a try; go for it!
Description
Summary of Changes
This PR migrates the integration tests for
crud/find
. The changes include:src
folderNotes for Reviewers
To simplify the review process there is a separate commit for .js -> .ts conversion.
What is the motivation for this change?
This work is part of a larger, ongoing initiative to convert all tests to use
async/await
, with the ultimate goal of removing the legacy driver wrapper.Double check the following
npm run check:lint
)type(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript