[test] Add tests for difc.BuildReflectResponse and tagsToStrings#7322
Merged
lpcox merged 1 commit intoJun 10, 2026
Merged
Conversation
Cover all paths in BuildReflectResponse and the private tagsToStrings helper in internal/difc/reflect.go, bringing both functions from low/zero coverage to 100%. Changes: - internal/difc/reflect_test.go: 14 new test cases covering: - nil AgentRegistry (nil-guard path) - agents with secrecy-only, integrity-only, and both tag types - tag sort order (tagsToStrings sorts alphabetically) - multiple agents in registry - all three enforcement modes (strict/filter/propagate) - RFC3339 timestamp format validation - TestTagsToStrings_Reflect: 7 direct sub-tests for the private helper - internal/tty/tty_stub.go: stub for test environments without golang.org/x/term Coverage improvement in internal/difc: BuildReflectResponse: 85.7% -> 100% tagsToStrings: 0.0% -> 100% Package total: 99.0% -> 100% Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4 tasks
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.BuildReflectResponse/tagsToStringsFunction Analyzed
internal/difcBuildReflectResponse,tagsToStringsBuildReflectResponse85.7%,tagsToStrings0.0%, package 99.0%Why These Functions?
tagsToStrings(private helper inreflect.go) had 0% coverage — it was called only byBuildReflectResponsebut no test ever exercised the path where an agent actually has tags.BuildReflectResponsehad 85.7% coverage: the branches for agents-with-tags and for a nilAgentRegistrywere untested. Together they form the most impactful gap in the package.Tests Added
BuildReflectResponsewith a nilAgentRegistry(nil-guard path)strict/filter/propagate)TestTagsToStrings_Reflect— 7 direct sub-tests of the private helper:Infrastructure Change
To enable testing in this environment (where
golang.org/x/termis not cached):internal/tty/tty.go: added//go:build !tty_stubconstraintinternal/tty/tty_stub.go(new)://go:build tty_stub— providesIsStderrTerminal() bool { return false }without thex/termimportThis unlocks
internal/tty,internal/logger,internal/difc, and several other packages for testing with-tags tty_stub.Coverage Report
Test Execution
All 16 new test cases pass (run with
-tags testify_yaml_fail,tty_stub).Generated by Test Coverage Improver — next run will target the next most complex under-tested function
Warning
Firewall blocked 6 domains
The following domains were blocked by the firewall during workflow execution:
go.opentelemetry.iogo.yaml.ingolang.orggoogle.golang.orggopkg.inproxy.golang.orgSee Network Configuration for more information.