-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test: Add unified spec runner scaffolding #2689
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
Conversation
7ebfbe3
to
c6c94be
Compare
return m; | ||
} | ||
|
||
getClient(key: string): UnifiedMongoClient { |
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 noticing a common pattern in the getters (getClient
, getDatabase
, getCollection
, getSession
). It seems there could be an opportunity here to refactor the common behaviour and reduce the code here... What do you think about creating a generic getEntity
method that takes the key and type and then checks the value is of the provided type and throws the error? Then each of the other methods would become one-liners?
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 agree, each of these methods also means we'd have a different stack trace for each one even though it is the same error, I've consolidated the helpers into getEntity
and mapOf
and I think it's friendly enough we don't need the bespoke methods any more, getEntity with a type param works nicely!
return e; | ||
} | ||
|
||
databases(): Map<string, Db> { |
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 also seeing the same pattern for getting maps of certain types - I think this could also be refactored to turn databases
, collections
, sessions
, buckets
, etc into one-liners as well.
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.
Suggested a few typo fixes in comments but LGTM 👍
context(String(unifiedSuite.description), function runUnifiedTest() { | ||
for (const test of unifiedSuite.tests) { | ||
it(String(test.description), async function runOneUnifiedTest() { | ||
// Function call for indentation sake... |
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 think this comment is a bit confusing and could be removed or reworded
ctx.defer(async () => await entities.cleanup()); | ||
|
||
// Workaround for SERVER-39704: | ||
// a test runners MUST execute a non-transactional distinct command on |
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.
// a test runners MUST execute a non-transactional distinct command on | |
// test runners MUST execute a non-transactional distinct command on |
specialCheck(result, operation.expectResult); | ||
} else { | ||
for (const [resultKey, resultValue] of Object.entries(operation.expectResult)) { | ||
// each key/value expectation can be is a special op |
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.
// each key/value expectation can be is a special op | |
// each key/value expectation can be a special op |
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.
Nice refactor! LGTM
Using the unfied spec test schema this scaffolding outlines the structure of a unified runner. Most tests are skipped by the runOn requirements or not implemented errors thrown by empty operation functions. NODE-2287
9d2524f
to
bec50e6
Compare
Using the unified spec test schema this scaffolding
outlines the structure of a unified runner. Most tests
are skipped by the runOn requirements or not implemented
errors thrown by empty operation functions.
NODE-2287