Skip to content

test(render): add comprehensive tests for MsgPack render#4537

Merged
appleboy merged 2 commits into
gin-gonic:masterfrom
Amirhf1:test/render-msgpack
Feb 17, 2026
Merged

test(render): add comprehensive tests for MsgPack render#4537
appleboy merged 2 commits into
gin-gonic:masterfrom
Amirhf1:test/render-msgpack

Conversation

@Amirhf1
Copy link
Copy Markdown
Contributor

@Amirhf1 Amirhf1 commented Feb 16, 2026

Description (What does this PR do?)
This PR adds missing unit tests for MsgPack rendering as identified by the TODO comment in render/render_msgpack_test.go

Changes:

  • Added TestWriteMsgPack: Verifies the WriteMsgPack function correctly encodes data and sets headers.
  • Added TestRenderMsgPackError: Adds robust error handling test using a failWriter to simulate write errors during rendering, ensuring proper error propagation.
  • Removed TODO comments as the tests are now implemented.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.01%. Comparing base (3dc1cd6) to head (93e3206).
⚠️ Report is 249 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4537      +/-   ##
==========================================
- Coverage   99.21%   99.01%   -0.21%     
==========================================
  Files          42       46       +4     
  Lines        3182     3038     -144     
==========================================
- Hits         3157     3008     -149     
- Misses         17       21       +4     
- Partials        8        9       +1     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 99.00% <ø> (?)
-tags go_json 98.93% <ø> (?)
-tags nomsgpack 98.99% <ø> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.24 99.01% <ø> (?)
go-1.25 99.01% <ø> (?)
macos-latest 99.01% <ø> (-0.21%) ⬇️
ubuntu-latest 99.01% <ø> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Decode the rendered msgpack output and assert values instead of comparing raw bytes (which can vary with map iteration order).
Enable MsgpackHandle.RawToString so msgpack strings decode as Go strings.
@appleboy appleboy added the test label Feb 17, 2026
@appleboy appleboy added this to the v1.12 milestone Feb 17, 2026
@appleboy appleboy merged commit 216a4a7 into gin-gonic:master Feb 17, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants