-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Replace go-github-mock with stretchr/testify for actions/issues/projects tests #1737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 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>
pkg/github/actions_test.go
Outdated
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func newMockedHTTPClient(handlers map[string]http.HandlerFunc) *http.Client { |
There was a problem hiding this comment.
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 fix tests and lint the code |
There was a problem hiding this 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-mockwithMockHTTPClientWithHandlersfor REST API mocking in three test files - Removed the
go-github-mockimport 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 functiongithubv4MockHTTPClientWithHandlersin issues_test.go (lines 1428, 1451, 1739)⚠️ 1 missing constantGetReposActionsRunsByOwnerByRepoin 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>
kerobbi
left a comment
There was a problem hiding this 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!
pkg/github/projects_test.go
Outdated
| 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| mock "github.com/migueleliasweb/go-github-mock/src/mock" | |
| "github.com/migueleliasweb/go-github-mock/src/mock" |
SamMorrowDrums
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
sfosss
left a comment
There was a problem hiding this 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
Summary
Closes #1492
Why
To reduce number of dependencies.
What changed
MCP impact
Prompts tested (tool changes only)
Security / limits
Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lint./script/testDocs
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.