Skip to content

test: add comprehensive tests to improve coverage#240

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/analyze-test-coverage
Closed

test: add comprehensive tests to improve coverage#240
Copilot wants to merge 1 commit intomainfrom
copilot/analyze-test-coverage

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 5, 2026

Summary

Analyzes and improves test coverage across the codebase. Before this PR, overall statement coverage was 10.5% with 6 packages at 0%.

Changes

Bug fix

  • internal/athena/pos_test.go — Corrected a wrong test expectation: the test expected /123 to not match commandRegex, but the regex (^/[a-z0-9]+(-[a-z0-9]+)*) and its own code comment explicitly allow numeric commands like /51. This caused a pre-existing test failure.

New test files

File Before After
internal/sliceutil/sliceutil_test.go 0% 100%
internal/permissions/permissions_test.go 0% 100%
internal/packet/packet_test.go 0% 100%
internal/playercount/playercount_test.go 0% 100%
internal/uidheap/uidheap_test.go 0% 100%
internal/webhook/webhook_extra_test.go 4.7% 62.5%
internal/area/area_extra_test.go 21.1% 53.4%
internal/settings/settings_test.go 0% 42.6%

What each test file covers

  • sliceutilContainsString / ContainsInt with found, not-found, empty, nil, and edge-value cases
  • permissionsGetPermissions (empty, single, multi-perm, admin), HasPermission (exact, superset, missing, admin), IsModerator (no-perm, CM-only, kick, admin)
  • packetNewPacket (header-only, with body, trailing-# stripping, empty/whitespace header errors), String (no body, with body, empty field), roundtrip through network-layer stripping
  • playercountGetPlayerCount, AddPlayer, RemovePlayer, symmetric add/remove, concurrent add/remove with -race
  • uidheapPush/Pop, Less, Swap, Len, min-heap ordering verification
  • webhook — empty-URL early-returns for all 6 post functions, HTTP error response, negative-UID "N/A" rendering
  • area — HP bounds/validation, Status, Lock, Background, Buffer ring-rotation, Reset, PlayerCount/VisiblePlayerCount, LastSpeaker, SpectateInvited, SpectateMode clearing invite list, ClearInvited, SwapEvidence out-of-bounds, Taken helper, SwitchChar-to-spectator, EvidenceMode get/set
  • settingsDefaultConfig field spot-checks, LoadFile success/missing/empty, GetConfig with TOML overrides and missing file

Overall coverage: 10.5% → 12.5%

All tests pass with -race.

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.

2 participants