Skip to content

refactor: Use testBody for consistency#4170

Open
alexandear wants to merge 1 commit intogoogle:masterfrom
alexandear-org:refactor/test-body
Open

refactor: Use testBody for consistency#4170
alexandear wants to merge 1 commit intogoogle:masterfrom
alexandear-org:refactor/test-body

Conversation

@alexandear
Copy link
Copy Markdown
Contributor

Refactor tests to use the testBody helper instead of assertNilError(t, json.NewDecoder(r.Body).Decode(&v)). This significantly simplifies tests.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.70%. Comparing base (971b607) to head (29c3521).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants