Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove test that can panic#445

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

williammartin
Copy link
Collaborator

@williammartinwilliammartin commentedMay 27, 2025
edited
Loading

Description

This PR removes a test that was both trying to simulate an error that can't happen, and causing bizarre failures elsewhere. For example, when another test failed (simulated with at.FailNow inTest_GetMe, it would also get this panic:

➜  github-mcp-server git:(main) go test -count=1 ./pkg/github--- FAIL: Test_GetMe (0.00s)2025/05/27 19:50:15 http: panic serving 127.0.0.1:62114: go-github-mock: no more mocks available for /repos/owner/repo/contents/srcgoroutine 629 [running]:net/http.(*conn).serve.func1()        /opt/homebrew/opt/go/libexec/src/net/http/server.go:1947 +0xb0panic({0x104ec20c0?, 0x14000c0a030?})        /opt/homebrew/opt/go/libexec/src/runtime/panic.go:792 +0x124github.com/migueleliasweb/go-github-mock/src/mock.(*FIFOResponseHandler).ServeHTTP(0x14000c16140?, {0x104fb8fb0?, 0x140008c4a80?}, 0x0?)        /Users/williammartin/go/pkg/mod/github.com/migueleliasweb/go-github-mock@v1.3.0/src/mock/server.go:41 +0x1b8github.com/gorilla/mux.(*Router).ServeHTTP(0x14000147140, {0x104fb8fb0, 0x140008c4a80}, 0x14000c16000)        /Users/williammartin/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x194net/http.serverHandler.ServeHTTP({0x14000c020f0?}, {0x104fb8fb0?, 0x140008c4a80?}, 0x1?)        /opt/homebrew/opt/go/libexec/src/net/http/server.go:3301 +0xbcnet/http.(*conn).serve(0x1400071c480, {0x104fb9390, 0x140006d8510})        /opt/homebrew/opt/go/libexec/src/net/http/server.go:2102 +0x52ccreated by net/http.(*Server).Serve in goroutine 956        /opt/homebrew/opt/go/libexec/src/net/http/server.go:3454 +0x3d8FAILFAIL    github.com/github/github-mcp-server/pkg/github  0.306sFAIL

This is because:

mockedClient:mock.NewMockedHTTPClient(mock.WithRequestMatch(mock.GetReposContentsByOwnerByRepoByPath,),),

Was registering a handler with no responses which would then panic here when a request came in:https://github.com/migueleliasweb/go-github-mock/blob/dd6b28752862d0748bf5cee28fc1d69b0475eb3f/src/mock/server.go#L40-L45

Unfortunately, this panic would never bubble up a test failure in this test, but presumably because it was in a goroutine, would asynchronously result in strange failures in other places. Haven't totally dug into why because it's not that important beyond fixing it.

@CopilotCopilotAI review requested due to automatic review settingsMay 27, 2025 18:06
@williammartinwilliammartin requested a review froma team as acode ownerMay 27, 2025 18:06
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

SamMorrowDrums
SamMorrowDrums previously approved these changesMay 27, 2025
"path": []string{"src"},
},
expectedResult: nil,
expectError: "no repository resource content found",
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

Also, thisexpectError field is never actually used because all the tests setexpectedErrorMsg.

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

@williammartinwilliammartin merged commit7e026fc intomainMay 27, 2025
16 checks passed
@williammartinwilliammartin deleted the wm/fix-non-isolated-repository-resource-tests branchMay 27, 2025 18:29
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@SamMorrowDrumsSamMorrowDrumsSamMorrowDrums approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@williammartin@SamMorrowDrums

[8]ページ先頭

©2009-2025 Movatter.jp