Skip to content

Commit 1755ad4

Browse files
committed
test(billing): cover rzpNotes json.Unmarshal error branch (non-string value)
100%-patch: a notes object with a non-string value exercises the decode-error path in rzpNotes.UnmarshalJSON (billing.go:1372-1373).
1 parent ae2a419 commit 1755ad4

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

internal/handlers/billing_notes_unmarshal_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ func TestRzpNotes_ToleratesArrayObjectAndNull(t *testing.T) {
4646
}
4747
})
4848

49+
// A malformed object (non-string value) must surface the decode error rather
50+
// than silently swallow it — covers the json.Unmarshal error branch.
51+
t.Run("object with non-string value errors", func(t *testing.T) {
52+
t.Parallel()
53+
var p rzpPaymentEntity
54+
err := json.Unmarshal([]byte(`{"id":"p","notes":{"k":123}}`), &p)
55+
if err == nil {
56+
t.Fatal("a notes object with a non-string value must return a decode error, not be swallowed")
57+
}
58+
})
59+
4960
// null and empty-array on the subscription entity → empty map, no error.
5061
for _, tc := range []struct{ name, body string }{
5162
{"null", `{"id":"s","notes":null}`},

0 commit comments

Comments
 (0)