[SERVER-78457] Remove assert.commandFailed() and assert.throws() Created: 26/Jun/23 Updated: 10/Oct/23 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Engineering Test | Priority: | Major - P3 |
| Reporter: | Judah Schvimer | Assignee: | Backlog - Service Architecture |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | make-server-testing-joyful | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Service Arch
|
||||||||
| Participants: | |||||||||
| Description |
|
As max.hirschhorn@mongodb.com said well, "assert.commandFailedWithCode() should always be preferred over assert.commandFailed() because it is possible to write the input parameters to a command incorrectly where it fails with BadValue/TypeMismatch/FailedToParse/etc. and means the test isn't exercising what it intended". assert.throws has the same problem and assert.throwsWithCode should be used instead. |
| Comments |
| Comment by Judah Schvimer [ 11/Jul/23 ] | ||||
|
matt.broadstone@mongodb.com said he can easily automate this with his javascript modernization efforts. | ||||
| Comment by David Storch [ 06/Jul/23 ] | ||||
|
There are quite a few callers of these two functions in the code base:
judah.schvimer@mongodb.com do you know why this was assigned to the Query Optimization team? If we want to tackle this across core server contributors, I think it would be best to divide and conquer. Each team could be responsible for fixing the tests that they own. | ||||
| Comment by Max Hirschhorn [ 26/Jun/23 ] | ||||
I believe there are cases where the generated Error object won't have a .code property ( |