test(handlers): team/membership handlers to ≥95% coverage#152
Merged
Conversation
Adds DB-backed + sqlmock + in-package unit tests covering every team handler file (teams.go, team_self.go, team_members.go, team_settings.go, team_summary.go, team_deletion.go): list/invite/remove/role/promote/leave members, RBAC invitation create/list/revoke/accept, team settings, team summary, and the team deletion/restore lifecycle — including each error, permission, and best-effort-audit branch. Per-file statement coverage after this change: teams.go 98.9% team_self.go 100.0% team_members.go 95.6% team_settings.go 100.0% team_summary.go 96.4% team_deletion.go 97.0% Branches that remain uncovered are unreachable defensive code (e.g. signSessionJWT failure under a valid config, the PortalSubscriptionCanceler "no live subscription" path that needs the live Razorpay portal). The error-mapping switches (teamsModelError / teamMembersModelError) are exercised directly via an in-package table test so every arm — including the defensive ones the handlers can't produce — is locked against drift. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
teamsModelError/teamMembersModelErrorswitches so every arm is locked against drift.Remaining uncovered lines are unreachable defensive code (signSessionJWT failure under a valid config; the
PortalSubscriptionCanceler"no live subscription" path that needs the live Razorpay portal).Test plan
go build ./...cleango vet ./internal/handlerscleango test ./internal/handlers -run 'TestTeam|TestMember|TestInvit|TestPAT|TestToken' -count=1 -p 1greengo tool cover -func🤖 Generated with Claude Code