(t *testing.T)
| 1000 | } |
| 1001 | |
| 1002 | func TestAssignCopilotToIssue(t *testing.T) { |
| 1003 | t.Parallel() |
| 1004 | |
| 1005 | if getE2EHost() != "" && getE2EHost() != "https://github.com" { |
| 1006 | t.Skip("Skipping test because the host does not support copilot being assigned to issues") |
| 1007 | } |
| 1008 | |
| 1009 | mcpClient := setupMCPClient(t) |
| 1010 | ctx := context.Background() |
| 1011 | |
| 1012 | // First, who am I |
| 1013 | |
| 1014 | t.Log("Getting current user...") |
| 1015 | resp, err := mcpClient.CallTool(ctx, &mcp.CallToolParams{Name: "get_me"}) |
| 1016 | require.NoError(t, err, "expected to call 'get_me' tool successfully") |
| 1017 | require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp)) |
| 1018 | |
| 1019 | require.False(t, resp.IsError, "expected result not to be an error") |
| 1020 | require.Len(t, resp.Content, 1, "expected content to have one item") |
| 1021 | |
| 1022 | textContent, ok := resp.Content[0].(*mcp.TextContent) |
| 1023 | require.True(t, ok, "expected content to be of type TextContent") |
| 1024 | |
| 1025 | var trimmedGetMeText struct { |
| 1026 | Login string `json:"login"` |
| 1027 | } |
| 1028 | err = json.Unmarshal([]byte(textContent.Text), &trimmedGetMeText) |
| 1029 | require.NoError(t, err, "expected to unmarshal text content successfully") |
| 1030 | |
| 1031 | currentOwner := trimmedGetMeText.Login |
| 1032 | |
| 1033 | // Then create a repository with a README (via autoInit) |
| 1034 | repoName := fmt.Sprintf("github-mcp-server-e2e-%s-%d", t.Name(), time.Now().UnixMilli()) |
| 1035 | |
| 1036 | t.Logf("Creating repository %s/%s...", currentOwner, repoName) |
| 1037 | _, err = mcpClient.CallTool(ctx, &mcp.CallToolParams{ |
| 1038 | Name: "create_repository", |
| 1039 | Arguments: map[string]any{ |
| 1040 | "name": repoName, |
| 1041 | "private": true, |
| 1042 | "autoInit": true, |
| 1043 | }, |
| 1044 | }) |
| 1045 | require.NoError(t, err, "expected to call 'create_repository' tool successfully") |
| 1046 | require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp)) |
| 1047 | |
| 1048 | // Cleanup the repository after the test |
| 1049 | t.Cleanup(func() { |
| 1050 | // MCP Server doesn't support deletions, but we can use the GitHub Client |
| 1051 | ghClient := getRESTClient(t) |
| 1052 | t.Logf("Deleting repository %s/%s...", currentOwner, repoName) |
| 1053 | _, err := ghClient.Repositories.Delete(context.Background(), currentOwner, repoName) |
| 1054 | require.NoError(t, err, "expected to delete repository successfully") |
| 1055 | }) |
| 1056 | |
| 1057 | // Create an issue |
| 1058 | |
| 1059 | t.Logf("Creating issue in %s/%s...", currentOwner, repoName) |
nothing calls this directly
no test coverage detected