(t *testing.T)
| 1266 | } |
| 1267 | |
| 1268 | func TestPullRequestReviewCommentSubmit(t *testing.T) { |
| 1269 | t.Parallel() |
| 1270 | |
| 1271 | mcpClient := setupMCPClient(t) |
| 1272 | |
| 1273 | ctx := context.Background() |
| 1274 | |
| 1275 | // First, who am I |
| 1276 | |
| 1277 | t.Log("Getting current user...") |
| 1278 | resp, err := mcpClient.CallTool(ctx, &mcp.CallToolParams{Name: "get_me"}) |
| 1279 | require.NoError(t, err, "expected to call 'get_me' tool successfully") |
| 1280 | require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp)) |
| 1281 | |
| 1282 | require.False(t, resp.IsError, "expected result not to be an error") |
| 1283 | require.Len(t, resp.Content, 1, "expected content to have one item") |
| 1284 | |
| 1285 | textContent, ok := resp.Content[0].(*mcp.TextContent) |
| 1286 | require.True(t, ok, "expected content to be of type TextContent") |
| 1287 | |
| 1288 | var trimmedGetMeText struct { |
| 1289 | Login string `json:"login"` |
| 1290 | } |
| 1291 | err = json.Unmarshal([]byte(textContent.Text), &trimmedGetMeText) |
| 1292 | require.NoError(t, err, "expected to unmarshal text content successfully") |
| 1293 | |
| 1294 | currentOwner := trimmedGetMeText.Login |
| 1295 | |
| 1296 | // Then create a repository with a README (via autoInit) |
| 1297 | repoName := fmt.Sprintf("github-mcp-server-e2e-%s-%d", t.Name(), time.Now().UnixMilli()) |
| 1298 | |
| 1299 | t.Logf("Creating repository %s/%s...", currentOwner, repoName) |
| 1300 | _, err = mcpClient.CallTool(ctx, &mcp.CallToolParams{ |
| 1301 | Name: "create_repository", |
| 1302 | Arguments: map[string]any{ |
| 1303 | "name": repoName, |
| 1304 | "private": true, |
| 1305 | "autoInit": true, |
| 1306 | }, |
| 1307 | }) |
| 1308 | require.NoError(t, err, "expected to call 'create_repository' tool successfully") |
| 1309 | require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp)) |
| 1310 | |
| 1311 | // Cleanup the repository after the test |
| 1312 | t.Cleanup(func() { |
| 1313 | // MCP Server doesn't support deletions, but we can use the GitHub Client |
| 1314 | ghClient := getRESTClient(t) |
| 1315 | t.Logf("Deleting repository %s/%s...", currentOwner, repoName) |
| 1316 | _, err := ghClient.Repositories.Delete(context.Background(), currentOwner, repoName) |
| 1317 | require.NoError(t, err, "expected to delete repository successfully") |
| 1318 | }) |
| 1319 | |
| 1320 | // Create a branch on which to create a new commit |
| 1321 | |
| 1322 | t.Logf("Creating branch in %s/%s...", currentOwner, repoName) |
| 1323 | resp, err = mcpClient.CallTool(ctx, &mcp.CallToolParams{ |
| 1324 | Name: "create_branch", |
| 1325 | Arguments: map[string]any{ |
nothing calls this directly
no test coverage detected