refactor: Use testBody for consistency#4170
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4170 +/- ##
=======================================
Coverage 93.70% 93.70%
=======================================
Files 210 210
Lines 19692 19692
=======================================
Hits 18453 18453
Misses 1045 1045
Partials 194 194 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @alexandear - my only concern with this change is that it now makes it more difficult to write the unit tests, as you need to know what the body is going to look like instead of allowing the test harnest ensure that what went in actually came out.
I suppose a test writer could use "" for the body on the first pass, run the test, then copy/paste the "got" into the "want"... but that is certainly not idea. Speaking of this, I really like the MoonBit inspect tooling that will automatically update the "want" part when run with certain flags.
Also, if you modify the testBody methods itself to simply insist that a body always ends with "\n" then you can remove hundreds of instances of +"\n" which would dramatically clean things up even more.
Thoughts?
Refactor tests to use the
testBodyhelper instead ofassertNilError(t, json.NewDecoder(r.Body).Decode(&v)). This significantly simplifies tests.