[test] Add tests for server.copyToolCallLimits#6766
Merged
lpcox merged 2 commits intoMay 31, 2026
Conversation
Direct unit tests for the copyToolCallLimits helper, which was previously exercised only indirectly through ensureGuardInitialized integration tests. Tests cover: - nil and empty-map inputs return nil - single and multiple entries are copied correctly - keys with surrounding whitespace are trimmed (the key normalization path) - zero and negative limit values are preserved - returned map is a defensive copy — mutations to the copy do not affect the original and vice versa Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds focused unit coverage for internal/server.copyToolCallLimits, ensuring the helper’s defensive-copy and key-normalization behavior is explicitly verified without going through heavier initialization paths.
Changes:
- Introduces table-driven tests covering nil/empty inputs, single/multi-entry copies, whitespace-trimmed keys, and preservation of zero/negative limits.
- Adds isolation tests asserting mutations to either the original map or the returned copy do not affect the other.
Show a summary per file
| File | Description |
|---|---|
| internal/server/copy_tool_call_limits_test.go | New unit tests covering all branches and copy/isolation semantics of copyToolCallLimits. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
Test Coverage Improvement:
copyToolCallLimitsFunction Analyzed
internal/servercopyToolCallLimitsWhy This Function?
copyToolCallLimitsis a security-significant helper: it creates a per-session defensive copy of the guard policy's tool-call-limit map so that later config mutations cannot affect in-flight sessions. Despite its importance it had zero direct test coverage — it was only reachable through the heavyweightensureGuardInitializedpath.The function has a subtle key-normalisation step (
strings.TrimSpace) that needed explicit verification, and the isolation guarantee (copy ↔ original independence) had never been asserted.Tests Added
nilinput returnsnilnilCoverage Report
Generated by Test Coverage Improver
Next run will target the next most complex under-tested function
Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
proxy.golang.orgreleaseassets.githubusercontent.comSee Network Configuration for more information.