Skip to content

test(cmd): add CLI workflow coverage and harden GitHub null handling#3

Merged
mnencia merged 3 commits into
mainfrom
test/cmd-workflow-coverage
Mar 18, 2026
Merged

test(cmd): add CLI workflow coverage and harden GitHub null handling#3
mnencia merged 3 commits into
mainfrom
test/cmd-workflow-coverage

Conversation

@mnencia

@mnencia mnencia commented Mar 18, 2026

Copy link
Copy Markdown
Owner

Summary

Adds focused tests for the main CLI workflow and hardens GitHub GraphQL parsing when issue or pullRequest comes back null.

Changes

  • add cmd/root.go workflow tests for dry-run create flow
  • add duplicate/update flow coverage for PR-to-issue canonicalization
  • route CLI output through Cobra's writer for testability
  • return explicit errors for missing GraphQL issue/PR objects
  • refresh AGENT.md to reflect current CI/release setup and recommend golangci-lint

Validation

  • go vet ./...
  • golangci-lint run ./...
  • go test ./...

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 == null or repository.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.

mnencia and others added 2 commits March 18, 2026 14:09
…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>
@mnencia mnencia merged commit dda01c3 into main Mar 18, 2026
1 check passed
@mnencia mnencia deleted the test/cmd-workflow-coverage branch March 18, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants