test(render): satisfy testifylint for AsciiJSON non-BMP check

Use assert.Contains for the exact UTF-16 surrogate pair wire encoding
and assert.JSONEq for semantic equality, instead of assert.Equal on a
JSON string which testifylint rejects.
This commit is contained in:
RubenPari 2026-08-09 22:37:11 +02:00
parent e89c60b4e4
commit 9aeac9b417

View File

@ -277,8 +277,10 @@ func TestRenderAsciiJSONNonBMP(t *testing.T) {
err := (AsciiJSON{Data: data}).Render(w)
require.NoError(t, err)
// Non-BMP characters must be encoded as UTF-16 surrogate pairs
assert.Equal(t, `{"msg":"\ud83d\ude00"}`, w.Body.String())
body := w.Body.String()
// Non-BMP characters must be encoded as UTF-16 surrogate pairs on the wire.
assert.Contains(t, body, `\ud83d\ude00`)
assert.JSONEq(t, `{"msg":"😀"}`, body)
// Verify round-trip: json.Unmarshal should recover the original emoji
var decoded map[string]string