-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test: write concern test cleanup #2342
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
I agree with you that these tests are a whole bunch of copy-pasta! Your approach looks similar to the ReplSetFixture we used in some of our core test, but I wonder if we can design a better way out of this situation.. Ultimately, we are testing command construction here. The tests boil down to something like the following:
where It might be a bit tricky to figure out at first, but I think we can use some existing examples of stubbing the |
Haha yeah as I was writing it I was thinking "this is a very general pattern, someone has probably done this before somewhere." Creating the class was simple though, so I didn't spend time grepping. The laborious part was stripping the boilerplate - it should be trivial to convert these tests to a better underlying paradigm now.
Agreed, this sounds like a better solution.
I'm not sure I see any benefit to that, since these tests feel like they should be unit tests since the server they are running against is irrelevant. I could see a future optimization to our evergreen setup where we only run unit tests once per environment, and then we'd have an incentive to keep tests that don't really need a server from using one. |
Great, glad we agree on the stubbed approach. I think we could very likely end up with a fantastic new helper like:
I'm sure there's something I'm missing here though, here are some thoughts that occur to me immediately:
|
…ep for stubbed client refactor
Yeah that would be awesome! I've refactored all of the tests to use a |
} | ||
} | ||
|
||
function withStubbedClient(testFn) { |
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.
Are you going to further refactor this to use sinon
or are we deferring that work to a later PR?
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.
Yeah I was planning to follow up by extracting withStubbedClient
to test/functional/shared.js
and making it use sinon
.
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.
follow up in this PR or a subsequent one? Just trying to decide on whether to approve or not :)
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.
There's no rush to get this cleanup in so might as well do it in this PR, I'll mark it as a draft for now.
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.
Created a ticket to track this work: NODE-2603
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.
Description
Cleans up duplication and deprecation warnings in write concern command construction tests.
What changed?
Are there any files to ignore?