Fix testifylint useless-assert error in TestGetWorkflowStatuses#16263
Fix testifylint useless-assert error in TestGetWorkflowStatuses#16263
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a testifylint lint failure in the CLI tests by removing a meaningless slice-length assertion in TestGetWorkflowStatuses, and includes a small formatting-only update to a Vitest expectation string.
Changes:
- Remove the always-true
len(statuses) >= 0assertion fromTestGetWorkflowStatuses. - Replace
statuses, err := ...with_, err := ...since the test isn’t validating returned data. - Reformat a long
toHaveBeenCalledWith(...)string literal in a JS unit test into a single line.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/cli/add_interactive_workflow_test.go | Removes the useless assertion and stops capturing an unused return value (but the updated test logic still contains redundant assertions). |
| actions/setup/js/log_parser_bootstrap.test.cjs | Formatting-only change to the expected failure message string. |
Comments suppressed due to low confidence (1)
pkg/cli/add_interactive_workflow_test.go:50
assert.Error(t, err, ...)is guarded byif err != nil, so the assertion can never fail and doesn’t add coverage (it may also trigger testifylint’s “useless assert” style checks). Remove this block or replace it with an assertion that can actually fail (e.g.,require.NotPanicsaround the call if that’s the goal).
if err != nil {
// Error is acceptable in test environment without gh CLI setup
assert.Error(t, err, "Expected error without gh CLI")
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _, err := getWorkflowStatuses(tt.pattern, tt.repoOverride, tt.verbose) | ||
|
|
||
| // Either succeeds or fails gracefully, but shouldn't panic | ||
| // Note: statuses may be nil even when err is nil (no workflows found) | ||
| if err != nil { |
There was a problem hiding this comment.
This test currently doesn’t actually validate anything: on the success path there are no assertions, and on the error path the if err != nil { assert.Error(t, err, ...) } check is redundant (and may still be flagged by testifylint as a useless assert). If the intent is purely “doesn’t panic”, wrap the call in require.NotPanics and drop the conditional assert entirely (optionally just ignore err or add a deterministic assertion via mocking).
This issue also appears on line 47 of the same file.
Linting failure:
testifylintflagged a meaningless assertion checking iflen(statuses) >= 0, which is always true for slices.Changes
pkg/cli/add_interactive_workflow_test.gostatuses, err := getWorkflowStatuses(...)to_, err := ...since the test only verifies the function doesn't panicBefore
After
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/repos/github/gh-aw/actions/workflows/usr/bin/gh gh workflow list --json name,state,path js/**/*.json' --ignore-path ../../../.prettierignore(http block)https://api.github.com/repos/owner/repo/actions/workflows/usr/bin/gh gh workflow list --json name,state,path --repo owner/repo de/node/bin/git(http block)/usr/bin/gh gh workflow list --json name,state,path --repo owner/repo(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.