Refactor audit_agent_output_test.go to idiomatic testify assertions#31255
Merged
pelikhan merged 5 commits intoMay 9, 2026
Merged
Conversation
8 tasks
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/816da665-bf41-42c9-b55c-8cbfc44a4d49 Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
This reverts commit c91fdf0. Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/816da665-bf41-42c9-b55c-8cbfc44a4d49 Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/816da665-bf41-42c9-b55c-8cbfc44a4d49 Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve test quality in audit_agent_output_test.go
Refactor May 9, 2026
audit_agent_output_test.go to idiomatic testify assertions
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors pkg/cli/audit_agent_output_test.go to use idiomatic testify/assert and testify/require assertions instead of manual t.Error* / t.Fatal* patterns.
Changes:
- Migrated assertions to
assert.*andrequire.*, including more contextual failure messages. - Introduced a small helper to reduce repetition when checking for expected finding categories.
- Tightened JSON structure checks using
assert.Containsandrequire.NoErrorfor marshal/unmarshal guards.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/audit_agent_output_test.go | Converts existing tests to testify-first style and adds a helper for category checks. |
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
Comment on lines
+120
to
124
| var failureFinding *Finding | ||
| for _, finding := range findings { | ||
| if finding.Category == "error" && strings.Contains(finding.Title, "Failed") { | ||
| found = true | ||
| if finding.Severity != "critical" { | ||
| t.Errorf("Expected critical severity for failure, got %s", finding.Severity) | ||
| } | ||
| failureFinding = &finding | ||
| break |
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.
This updates
pkg/cli/audit_agent_output_test.goto align with the repository’s testify-first test style. The file previously relied on manualt.Error/t.Errorf/t.Fatalfpatterns; this change standardizes assertions across findings, recommendations, performance metrics, and JSON structure checks.Assertion framework migration
assertandrequireimports.Critical-path checks moved to
requirerequire.*to stop invalid subtest execution early.Category/priority presence checks simplified
assert.True/assert.Condition) for clearer intent and failure output.JSON structure assertions tightened
assert.Containsfor expected top-level and nested fields.Example of the updated pattern:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name modules/@npmcli/run-script/lib/node-gyp-bin/sh GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu../../../**/*.json env w/js/**/*.json' --ignore-path .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linutest@example.com(http block)/usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name bin/node GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet tion�� itbranch_with_hyphen2201610585/001 itbranch_with_hyphen2201610585/002/work tions/node_modules/.bin/sh k/gh-aw/gh-aw/pkgit **/*.cjs erignore /opt/hostedtoolcremote.origin.url(http block)/usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw %H %ct %D(http block)https://api.github.com/orgs/owner/actions/secrets/usr/bin/gh gh api /orgs/owner/actions/secrets --jq .secrets[].name json' --ignore-path ../../../.pr**/*.json .cfg odules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/node GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet ules�� ll 2>&1 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet(http block)Agent-Log-U0 -main/autofind/autofind DefaultBranchFrogit DefaultBranchFroinit 1/x64/bin/node -main/autofind/autofind` (http block)
Agent-Logs-Url: REDACTED sv efaultBranchFrom/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet efaultBranchFrom-atomic` (http block)
Agent-Log-1` (http block)
Agent-Log-U0 sv 9flR8ruVS --write es/.bin/sh gh` (http block)
Agent-Log-U0 /node te '**/*.cjs' '*git -tests 1/x64/bin/node gh` (http block)