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

Function TestPullRequestAtomicCreateAndSubmit

e2e/e2e_test.go:1107–1266  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1105}
1106
1107func TestPullRequestAtomicCreateAndSubmit(t *testing.T) {
1108 t.Parallel()
1109
1110 mcpClient := setupMCPClient(t)
1111
1112 ctx := context.Background()
1113
1114 // First, who am I
1115
1116 t.Log("Getting current user...")
1117 resp, err := mcpClient.CallTool(ctx, &mcp.CallToolParams{Name: "get_me"})
1118 require.NoError(t, err, "expected to call 'get_me' tool successfully")
1119 require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))
1120
1121 require.False(t, resp.IsError, "expected result not to be an error")
1122 require.Len(t, resp.Content, 1, "expected content to have one item")
1123
1124 textContent, ok := resp.Content[0].(*mcp.TextContent)
1125 require.True(t, ok, "expected content to be of type TextContent")
1126
1127 var trimmedGetMeText struct {
1128 Login string `json:"login"`
1129 }
1130 err = json.Unmarshal([]byte(textContent.Text), &trimmedGetMeText)
1131 require.NoError(t, err, "expected to unmarshal text content successfully")
1132
1133 currentOwner := trimmedGetMeText.Login
1134
1135 // Then create a repository with a README (via autoInit)
1136 repoName := fmt.Sprintf("github-mcp-server-e2e-%s-%d", t.Name(), time.Now().UnixMilli())
1137
1138 t.Logf("Creating repository %s/%s...", currentOwner, repoName)
1139 _, err = mcpClient.CallTool(ctx, &mcp.CallToolParams{
1140 Name: "create_repository",
1141 Arguments: map[string]any{
1142 "name": repoName,
1143 "private": true,
1144 "autoInit": true,
1145 },
1146 })
1147 require.NoError(t, err, "expected to call 'get_me' tool successfully")
1148 require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))
1149
1150 // Cleanup the repository after the test
1151 t.Cleanup(func() {
1152 // MCP Server doesn't support deletions, but we can use the GitHub Client
1153 ghClient := getRESTClient(t)
1154 t.Logf("Deleting repository %s/%s...", currentOwner, repoName)
1155 _, err := ghClient.Repositories.Delete(context.Background(), currentOwner, repoName)
1156 require.NoError(t, err, "expected to delete repository successfully")
1157 })
1158
1159 // Create a branch on which to create a new commit
1160
1161 t.Logf("Creating branch in %s/%s...", currentOwner, repoName)
1162 resp, err = mcpClient.CallTool(ctx, &mcp.CallToolParams{
1163 Name: "create_branch",
1164 Arguments: map[string]any{

Callers

nothing calls this directly

Calls 3

setupMCPClientFunction · 0.85
getRESTClientFunction · 0.85
NameMethod · 0.80

Tested by

no test coverage detected