MCPcopy Index your code
hub / github.com/github/github-mcp-server / Test_RequestCopilotReview

Function Test_RequestCopilotReview

pkg/github/copilot_test.go:853–963  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

851}
852
853func Test_RequestCopilotReview(t *testing.T) {
854 t.Parallel()
855
856 serverTool := RequestCopilotReview(translations.NullTranslationHelper)
857 tool := serverTool.Tool
858 require.NoError(t, toolsnaps.Test(tool.Name, tool))
859
860 assert.Equal(t, "request_copilot_review", tool.Name)
861 assert.NotEmpty(t, tool.Description)
862 schema := tool.InputSchema.(*jsonschema.Schema)
863 assert.Contains(t, schema.Properties, "owner")
864 assert.Contains(t, schema.Properties, "repo")
865 assert.Contains(t, schema.Properties, "pullNumber")
866 assert.ElementsMatch(t, schema.Required, []string{"owner", "repo", "pullNumber"})
867
868 // Setup mock PR for success case
869 mockPR := &github.PullRequest{
870 Number: github.Ptr(42),
871 Title: github.Ptr("Test PR"),
872 State: github.Ptr("open"),
873 HTMLURL: github.Ptr("https://github.com/owner/repo/pull/42"),
874 Head: &github.PullRequestBranch{
875 SHA: github.Ptr("abcd1234"),
876 Ref: github.Ptr("feature-branch"),
877 },
878 Base: &github.PullRequestBranch{
879 Ref: github.Ptr("main"),
880 },
881 Body: github.Ptr("This is a test PR"),
882 User: &github.User{
883 Login: github.Ptr("testuser"),
884 },
885 }
886
887 tests := []struct {
888 name string
889 mockedClient *http.Client
890 requestArgs map[string]any
891 expectError bool
892 expectedErrMsg string
893 }{
894 {
895 name: "successful request",
896 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
897 PostReposPullsRequestedReviewersByOwnerByRepoByPullNumber: expect(t, expectations{
898 path: "/repos/owner/repo/pulls/1/requested_reviewers",
899 requestBody: map[string]any{
900 "reviewers": []any{"copilot-pull-request-reviewer[bot]"},
901 },
902 }).andThen(
903 mockResponse(t, http.StatusCreated, mockPR),
904 ),
905 }),
906 requestArgs: map[string]any{
907 "owner": "owner",
908 "repo": "repo",
909 "pullNumber": float64(1),
910 },

Callers

nothing calls this directly

Calls 14

TestFunction · 0.92
RequestCopilotReviewFunction · 0.85
expectFunction · 0.85
mockResponseFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85
getTextResultFunction · 0.85
andThenMethod · 0.80
WriteHeaderMethod · 0.80

Tested by

no test coverage detected