[test] Add tests for difc.SetSinkServerIDs and difc.IsSinkServerID#2063
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
[test] Add tests for difc.SetSinkServerIDs and difc.IsSinkServerID#2063github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
These two functions in internal/difc/sink_server_ids.go had 0% test coverage because they are only called from internal/cmd, which was not reachable from the unit test suite. Add a comprehensive test file covering all branches: - SetSinkServerIDs: empty/nil input (clears state), single ID, multiple IDs, sorted storage, duplicate deduplication, whitespace-only entries skipped, whitespace trimming, duplicates after trimming, mixed valid and whitespace entries, overwrite semantics - IsSinkServerID: empty configuration, exact match, case sensitivity, no partial matches, no whitespace matching - Integration tests combining both functions - Concurrent read/write safety tests Coverage improvement: SetSinkServerIDs: 0% → 100% IsSinkServerID: 0% → 100% internal/difc package: 93.8% → 99.7% Co-authored-by: Copilot <223556219+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:
difc.SetSinkServerIDsanddifc.IsSinkServerIDFunctions Analyzed
internal/difcSetSinkServerIDs,IsSinkServerIDinternal/difc/sink_server_ids.goSetSinkServerIDshas 7+ branches including dedup, trimming, sorting)Why These Functions?
SetSinkServerIDsandIsSinkServerIDhad 0% coverage because they are only called frominternal/cmd(which depends oncobra), making them unreachable from the unit test suite. Yet they implement critical DIFC (Decentralized Information Flow Control) sink configuration logic:SetSinkServerIDs: configures which backend MCP server IDs receive DIFC tag snapshot enrichment in RPC JSONL logs. Has complex branching: empty-input clearing, whitespace trimming, deduplication, and sorted storage.IsSinkServerID: thread-safe lookup into the configured set.Despite the 0% coverage, these functions have no existing test file at all (
sink_server_ids_test.godid not exist).Tests Added
"github"and" github "collapse to one entryCoverage Report
Generated by Test Coverage Improver
Next run will target the next most complex under-tested function
Warning
The following domains were blocked by the firewall during workflow execution:
go.yaml.ingolang.orggopkg.ininvalidhostthatdoesnotexist12345.comproxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.