Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

Summary

  • Migrates remaining tests toward the shared MockHTTPClientWithHandlers pattern.
  • Updates docs and licenses

Closes #1492

Why

To reduce number of dependencies.

What changed

  • Replaced custom helper with direct MockHTTPClientWithHandlers usage in Actions tests and aligned endpoints (including rerun/rerun-failed-jobs and cancel).
  • Restored required go-github-mock imports for Issues/Projects tests and added a minimal githubv4 mock helper alias so GraphQL tests compile.
  • Added the missing GetReposActionsRunsByOwnerByRepo test constant and reran lint/tests to ensure green.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Prompts tested (tool changes only)

  • N/A

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)
Original prompt

Start working on this comment: #1492 (comment)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits January 5, 2026 10:32
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Copilot AI changed the title [WIP] Address comments from issue 1492 Replace go-github-mock usage with internal testify-based mocks in tests Jan 5, 2026
Copilot AI requested a review from JoannaaKL January 5, 2026 10:45
@JoannaaKL
Copy link
Contributor

@copilot No, don't create new WithRequestMatchHandler and WithRequestMatch. Follow the pattern from other tests, for example git_test.go

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Copilot AI changed the title Replace go-github-mock usage with internal testify-based mocks in tests Replace go-github-mock usage in tests with shared HTTP mock helper Jan 5, 2026
"github.com/stretchr/testify/require"
)

func newMockedHTTPClient(handlers map[string]http.HandlerFunc) *http.Client {
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot remove it, create new MockHTTPClientWithHandlers by creating a new instance just as other tests do

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Copilot AI requested a review from JoannaaKL January 5, 2026 11:07
@JoannaaKL JoannaaKL marked this pull request as ready for review January 5, 2026 11:19
@JoannaaKL JoannaaKL requested a review from a team as a code owner January 5, 2026 11:19
Copilot AI review requested due to automatic review settings January 5, 2026 11:19
@JoannaaKL
Copy link
Contributor

@copilot fix tests and lint the code

Copy link
Contributor

Copilot AI left a comment

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 migrates Actions, Issues, and Projects tests from the migueleliasweb/go-github-mock library to the shared MockHTTPClientWithHandlers pattern used in other test files. The migration aims to standardize mock HTTP client usage across the test suite.

Key changes:

  • Replaced go-github-mock with MockHTTPClientWithHandlers for REST API mocking in three test files
  • Removed the go-github-mock import dependency from affected test files
  • Updated helper_test.go endpoint constant for sub-issue deletion (changed from plural to singular)

Critical Issues Found:

  • ⚠️ 3 instances of undefined function githubv4MockHTTPClientWithHandlers in issues_test.go (lines 1428, 1451, 1739)
  • ⚠️ 1 missing constant GetReposActionsRunsByOwnerByRepo in actions_test.go (line 1971)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
pkg/github/actions_test.go Migrated all REST mock setups from go-github-mock to MockHTTPClientWithHandlers; uses new endpoint constants but references undefined constant GetReposActionsRunsByOwnerByRepo
pkg/github/issues_test.go Migrated REST mock setups to MockHTTPClientWithHandlers; introduces undefined helper function githubv4MockHTTPClientWithHandlers for GraphQL mocks
pkg/github/projects_test.go Consistently replaced all go-github-mock instances with MockHTTPClientWithHandlers for empty handler maps in error test cases
pkg/github/helper_test.go Fixed DeleteReposIssuesSubIssueByOwnerByRepoByIssueNumber endpoint constant from plural "sub_issues" to singular "sub_issue"

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot fix tests and lint the code

Tests and lint now pass with the latest commit d76cda5.

Copilot AI changed the title Replace go-github-mock usage in tests with shared HTTP mock helper Stabilize test mocks and fix actions/issues/projects tests Jan 5, 2026
@JoannaaKL JoannaaKL changed the title Stabilize test mocks and fix actions/issues/projects tests Replace go-github-mock with stretchr/testify for actions/issues/projects tests Jan 5, 2026
Copy link
Contributor

@kerobbi kerobbi left a comment

Choose a reason for hiding this comment

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

just a nit, everything else lgtm!

gh "github.com/google/go-github/v79/github"
"github.com/google/jsonschema-go/jsonschema"
"github.com/migueleliasweb/go-github-mock/src/mock"
mock "github.com/migueleliasweb/go-github-mock/src/mock"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mock "github.com/migueleliasweb/go-github-mock/src/mock"
"github.com/migueleliasweb/go-github-mock/src/mock"

Copy link
Collaborator

@SamMorrowDrums SamMorrowDrums left a comment

Choose a reason for hiding this comment

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

Nice!

@JoannaaKL JoannaaKL merged commit 80b0306 into main Jan 6, 2026
16 checks passed
@JoannaaKL JoannaaKL deleted the copilot/work-on-issue-1492-comment branch January 6, 2026 09:45
Copy link

@sfosss sfosss left a comment

Choose a reason for hiding this comment

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

@copilot impliment and commit

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.

Chore: replace migueleliasweb/go-github-mock with stretchr/testify/mock

5 participants