Skip to content

test(handlers): raise billing-handler coverage#150

Merged
mastermanas805 merged 1 commit into
masterfrom
coverage/api-handlers-billing-95
May 22, 2026
Merged

test(handlers): raise billing-handler coverage#150
mastermanas805 merged 1 commit into
masterfrom
coverage/api-handlers-billing-95

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

  • Adds targeted unit/integration tests for the billing handler files (billing.go, brevo_webhook.go, billing_promotion.go, billing_usage.go).
  • Covers the full Razorpay-webhook event dispatch matrix, replay dedup, the ±5-minute timestamp guard, retryable-vs-non-retryable team-resolve paths, dunning dedup, payment-grace start/recovery, checkout reuse/create/promo paths, and the ChangePlan / ListInvoices / UpdatePayment branches.
  • Test-only change — no production source touched.

Coverage (isolated serial run, all tests PASS)

File Before After
brevo_webhook.go 94.4% 96.6%
billing_promotion.go 88.0% 98.7%
billing_usage.go 82.5% 100%
billing.go 73.4% 92.8%

billing.go falls short of 95%: the remaining lines are best-effort secondary-DB-write-error logs (need mid-handler fault injection) and Razorpay-API success response-shaping paths gated behind the razorpay-go client's hardcoded api.razorpay.com base URL — neither reachable without editing non-target source.

Test plan

  • go test ./internal/handlers -count=1 -p 1 passes on an isolated Postgres+Redis+Mongo DB (exit 0).
  • go vet ./internal/handlers clean.

🤖 Generated with Claude Code

Add targeted tests for the Razorpay-webhook event matrix (charged /
activated / cancelled / halted / completed / paused / resumed / pending /
charged_failed / deauthenticated / updated / refund), replay dedup, the
±5-minute timestamp guard, retryable-vs-non-retryable team-resolve paths,
dunning dedup, payment-grace recovery, the checkout reuse/create/promo
paths, ChangePlan/ListInvoices/UpdatePayment branches, and the brevo /
promotion / usage helpers. Test-only change.

Coverage (isolated serial run): brevo_webhook.go 96.6%, billing_promotion.go
98.7%, billing_usage.go 100%, billing.go 92.8% (the remaining billing.go
lines are best-effort secondary-write-error logs that need mid-handler fault
injection, and Razorpay-API success paths gated behind the razorpay-go
client's hardcoded base URL — neither reachable without editing non-target
source).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit d95a20f into master May 22, 2026
10 of 11 checks passed
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.

1 participant