Repository navigation
Improve safe-output helper test coverage - #75821
Conversation
Co-authored-by: gh-aw-bot <[email protected]>
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
❌ Design Decision Gate 🏗️ failed to deliver outputs during design decision gate check.
|
|
✅ Ponytail Reviewer completed successfully!
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found two test-quality gaps; no production correctness issue identified.
Findings
Details
- The sorting test uses
assert.JSONEq, so it does not verify serialized key order. - The duplicate-normalization test does not distinguish which colliding value wins.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| t.Run(tt.name, func(t *testing.T) { | ||
| jsonStr, err := buildNormalizedSortedJSON(tt.names, tt.valueFn) | ||
| require.NoError(t, err) | ||
| assert.JSONEq(t, tt.expected, jsonStr) |
There was a problem hiding this comment.
The sorting case does not actually verify sorted output because assert.JSONEq ignores object key order, and the repeatability check only compares two invocations.
💡 Verify the serialization order
Use an exact string assertion for this case (or explicitly compare key positions), so a regression that emits map order or otherwise unsorted keys is detected.
There was a problem hiding this comment.
Addressed in f37eb1d9: the normalized JSON test now compares the exact serialized string, so sorted key order is covered.
| CreatePullRequests: &CreatePullRequestsConfig{}, | ||
| }, | ||
| expected: false, | ||
| name: "collapses duplicate normalized names", |
There was a problem hiding this comment.
The duplicate-normalization case cannot detect which colliding value wins because the callback returns the same normalized name for both inputs.
💡 Make collision semantics observable
Use a stateful callback (for example, return distinct values on successive calls) and assert the documented/expected winner, so changes to duplicate handling do not silently pass.
There was a problem hiding this comment.
Addressed in f37eb1d9: the callback returns distinct successive values for colliding normalized names, and the expected JSON verifies the second value wins.
|
Warning The 🏗️ Design Decision Gate — ADR RequiredThis PR exceeds the ADR volume threshold with 229 added lines under 📄 Draft ADR committed:
📋 What to do next
Once the ADR is linked in this PR body, this gate will re-run and verify the implementation matches the decision. ❓ Why ADRs MatterADRs create a searchable, permanent record of why the codebase looks the way it does and make significant decisions reviewable by future contributors. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
What this change does: This PR expands safe-output helper coverage with table-driven nil, normalization, duplicate-name, sorting, and custom-job cases. It also moves the runtime checkout test into its own test file.
Nice to have:
-
Run each JSON case once (
pkg/workflow/safe_outputs_config_helpers_test.go:L57-L61)- What this is: Every normalized-JSON row calls the helper twice and manually compares the two results.
- Problem: The table already contains canonical JSON strings, so the second call and comparison branch add repeated test work.
- Fix: Keep the first
require.NoErrorand useassert.Equal(t, tt.expected, jsonStr); this checks the sorted bytes directly. - If we skip it: Each case retains an unnecessary second helper invocation and six lines of test code.
Verdict: fix 1 first.
Lean: -6 lines possible.
Generated by ✂️ Ponytail Reviewer for #75821 · codex · routed: gpt56 max · ~3 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again
| require.NoError(t, err) | ||
| assert.JSONEq(t, tt.expected, jsonStr) | ||
|
|
||
| repeatedJSON, err := buildNormalizedSortedJSON(tt.names, tt.valueFn) |
There was a problem hiding this comment.
What this is: The table runs buildNormalizedSortedJSON twice for every case and adds a manual comparison. Problem: The table already stores canonical JSON strings, so the second call and error branch add repeated work and test plumbing without another input. Fix: Keep the first require.NoError and replace the JSON assertion plus repeat block with assert.Equal(t, tt.expected, jsonStr); that checks sorted bytes directly. If we skip it: Every case keeps an unnecessary second helper invocation and six lines of test code.
There was a problem hiding this comment.
Addressed in f37eb1d9: removed the repeated helper invocation and compare the expected canonical output exactly.
There was a problem hiding this comment.
🟡 Changes recommended
The tests use assert.JSONEq, which ignores object-member order, so the new sorted-key behavior remains unverified in both reported cases.
1 open issue
What changed in this PR
Improves test coverage and organization for safe-output JSON helpers and runtime checkout detection.
Changes:
- Adds table-driven coverage for normalized, deduplicated, sorted, and repeatable JSON generation.
- Consolidates custom safe-output job serialization cases, including empty configurations and name normalization.
- Moves
TestUsesPatchesAndCheckoutsto the runtime-focused test file.
| File | Review |
|---|---|
pkg/workflow/safe_outputs_config_helpers_test.go |
Adds normalized JSON and custom-job test cases. Moderate issue (4 votes): assert.JSONEq does not verify sorted key order at lines 55 and 119; compare compact output directly or otherwise assert raw ordering. |
pkg/workflow/safe_outputs_runtime_test.go |
Houses checkout-detection tests alongside the runtime implementation. |
Review effort: Lite (auto)
| t.Run(tt.name, func(t *testing.T) { | ||
| jsonStr, err := buildNormalizedSortedJSON(tt.names, tt.valueFn) | ||
| require.NoError(t, err) | ||
| assert.JSONEq(t, tt.expected, jsonStr) |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd — requesting changes on two assertions that don't test what the PR description claims. No source bugs found; the three target tests pass and gofmt is clean.
📋 Key Themes & Highlights
Key Themes
- Weak ordering assertions:
assert.JSONEqis order-insensitive, so thesorts keysandmultiple sorted jobscases would still pass if sorting regressed. The PR says it covers sorted keys. - Verified:
TestUsesPatchesAndCheckoutsmoved intact (17 cases);TestBuildNormalizedSortedJSONcovers nil/empty, normalization, duplicate collapse, and repeatability; theMy.Custom-Job→{"My_Custom_Job":""}example is exercised.
Positive Highlights
- ✅ Table-driven consolidation removes the redundant unmarshalling assertions as intended.
- ✅ Moving the runtime checkout test next to the code it covers improves navigability.
Verification
go test ./pkg/workflow/ -run 'TestUsesPatchesAndCheckouts|TestBuildNormalizedSortedJSON|TestBuildCustomSafeOutputJobsJSON'passes onb6e9d447.- A throwaway byte-exact probe confirmed the current output is sorted, so switching to
assert.Equalshould pass.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 5.4K
Comment /matt to run again
| t.Run(tt.name, func(t *testing.T) { | ||
| jsonStr, err := buildNormalizedSortedJSON(tt.names, tt.valueFn) | ||
| require.NoError(t, err) | ||
| assert.JSONEq(t, tt.expected, jsonStr) |
There was a problem hiding this comment.
[/tdd] assert.JSONEq ignores key order, so the sorts keys case would still pass if the output order regressed. The expected strings are already in canonical order, so compare bytes exactly.
💡 Suggested change
assert.Equal(t, tt.expected, jsonStr)A byte-exact check pins the sorted-keys behaviour the PR description claims to cover.
@copilot please address this.
There was a problem hiding this comment.
Addressed in f37eb1d9: the sorted-key case now compares the serialized JSON string exactly.
| assert.Empty(t, jsonStr) | ||
| return | ||
| } | ||
| assert.JSONEq(t, tt.expected, jsonStr) |
There was a problem hiding this comment.
[/tdd] Same gap in the multiple sorted jobs case: assert.JSONEq accepts any key order, so a sorting regression in buildCustomSafeOutputJobsJSON would not be caught. Use byte-exact assert.Equal here as well.
@copilot please address this.
There was a problem hiding this comment.
Addressed in f37eb1d9: multiple custom jobs now use an exact serialized JSON string assertion to verify key order.
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: b6e9d44
|
Starting the requested work: I’m merging the latest Sous-chef requested-head: b6e9d44 |
Co-authored-by: gh-aw-bot <[email protected]>
Triage
|
|
PR triage: category=test | risk=low | total=35 | breakdown=impact 14, urgency 6, quality 15 | action=auto_merge | batch=pr-batch:quality-copilot
|
|
🎉 This pull request is included in a new release. Release: |

Tests did not directly cover normalized, sorted JSON generation, and custom safe-output job cases were split across separate tests. The runtime checkout test was also located alongside unrelated config-helper tests.
TestUsesPatchesAndCheckoutstosafe_outputs_runtime_test.go.Example expected output for
My.Custom-Job:{"My_Custom_Job":""}