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

Function TestPullRequestReviewDeletion

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

Source from the content-addressed store, hash-verified

1524}
1525
1526func TestPullRequestReviewDeletion(t *testing.T) {
1527 t.Parallel()
1528
1529 mcpClient := setupMCPClient(t)
1530
1531 ctx := context.Background()
1532
1533 // First, who am I
1534
1535 t.Log("Getting current user...")
1536 resp, err := mcpClient.CallTool(ctx, &mcp.CallToolParams{Name: "get_me"})
1537 require.NoError(t, err, "expected to call 'get_me' tool successfully")
1538 require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))
1539
1540 require.False(t, resp.IsError, "expected result not to be an error")
1541 require.Len(t, resp.Content, 1, "expected content to have one item")
1542
1543 textContent, ok := resp.Content[0].(*mcp.TextContent)
1544 require.True(t, ok, "expected content to be of type TextContent")
1545
1546 var trimmedGetMeText struct {
1547 Login string `json:"login"`
1548 }
1549 err = json.Unmarshal([]byte(textContent.Text), &trimmedGetMeText)
1550 require.NoError(t, err, "expected to unmarshal text content successfully")
1551
1552 currentOwner := trimmedGetMeText.Login
1553
1554 // Then create a repository with a README (via autoInit)
1555 repoName := fmt.Sprintf("github-mcp-server-e2e-%s-%d", t.Name(), time.Now().UnixMilli())
1556
1557 t.Logf("Creating repository %s/%s...", currentOwner, repoName)
1558 _, err = mcpClient.CallTool(ctx, &mcp.CallToolParams{
1559 Name: "create_repository",
1560 Arguments: map[string]any{
1561 "name": repoName,
1562 "private": true,
1563 "autoInit": true,
1564 },
1565 })
1566 require.NoError(t, err, "expected to call 'get_me' tool successfully")
1567 require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))
1568
1569 // Cleanup the repository after the test
1570 t.Cleanup(func() {
1571 // MCP Server doesn't support deletions, but we can use the GitHub Client
1572 ghClient := getRESTClient(t)
1573 t.Logf("Deleting repository %s/%s...", currentOwner, repoName)
1574 _, err := ghClient.Repositories.Delete(context.Background(), currentOwner, repoName)
1575 require.NoError(t, err, "expected to delete repository successfully")
1576 })
1577
1578 // Create a branch on which to create a new commit
1579
1580 t.Logf("Creating branch in %s/%s...", currentOwner, repoName)
1581 resp, err = mcpClient.CallTool(ctx, &mcp.CallToolParams{
1582 Name: "create_branch",
1583 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