test(cmd): add CLI workflow coverage and harden GitHub null handling#3
Merged
Conversation
Refresh AGENT.md to mention current CI/release behavior and recommend golangci-lint for local linting. Add regression tests for the main CLI workflow and harden GitHub GraphQL handling when issue or pull request objects are null. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves CLI reliability and testability by adding end-to-end-ish workflow tests for cmd/root.go, routing CLI output through Cobra’s configured writer, and hardening GitHub GraphQL parsing to return explicit errors when issue/pullRequest nodes are null.
Changes:
- Add focused CLI workflow tests covering dry-run create and update/duplicate flows (including PR→issue canonicalization).
- Route CLI output through
cmd.OutOrStdout()(via a small writer helper) and inject key dependencies to enable mocking in tests. - Return explicit errors when GitHub GraphQL responses contain
repository.issue == nullorrepository.pullRequest == null, plus add unit tests for those cases. - Update AGENT.md to reflect current CI/release tooling and config docs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/github/client.go | Treat GraphQL repository/issue/pullRequest nodes as pointers and error out on missing objects. |
| internal/github/client_test.go | Add tests ensuring missing issue/PR nodes return clear errors. |
| cmd/root.go | Make CLI output testable via Cobra writer; inject config/GitHub/Jira deps for mocking. |
| cmd/root_test.go | Add CLI workflow tests for dry-run create and update behavior with canonicalization. |
| AGENT.md | Refresh repository tooling/CI notes and document merged_pr status. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…nd test coverage Introduce a lineWriter struct that accumulates the first write error, replacing 20+ repetitive if-err-writeLine blocks with simple printf calls. Guard both UpdateDescription and CreateIssue behind out.err checks for consistent side-effect safety. Expand cmd test suite from 2 to 17 tests covering create, update, dry-run, status transitions, multiple/abandoned existing issues, user resolution failure, and all error paths. Harden test infrastructure with t.Cleanup, safe default stubs in swapCommandDeps, and multi-failure reporting in assertContainsAll. Add repository-null test cases for the GitHub client. Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
Make lineWriter output errors consistent across dry-run and non-dry-run paths, and add regression coverage for failing writers. 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.
Summary
Adds focused tests for the main CLI workflow and hardens GitHub GraphQL parsing when issue or pullRequest comes back null.
Changes
Validation