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

Function TestGetMe

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

Source from the content-addressed store, hash-verified

250}
251
252func TestGetMe(t *testing.T) {
253 t.Parallel()
254
255 mcpClient := setupMCPClient(t)
256 ctx := context.Background()
257
258 // When we call the "get_me" tool
259 response, err := mcpClient.CallTool(ctx, &mcp.CallToolParams{Name: "get_me"})
260 require.NoError(t, err, "expected to call 'get_me' tool successfully")
261
262 require.False(t, response.IsError, fmt.Sprintf("expected result not to be an error: %+v", response))
263 require.Len(t, response.Content, 1, "expected content to have one item")
264
265 textContent, ok := response.Content[0].(*mcp.TextContent)
266 require.True(t, ok, "expected content to be of type TextContent")
267
268 var trimmedContent struct {
269 Login string `json:"login"`
270 }
271 err = json.Unmarshal([]byte(textContent.Text), &trimmedContent)
272 require.NoError(t, err, "expected to unmarshal text content successfully")
273
274 // Then the login in the response should match the login obtained via the same
275 // token using the GitHub API.
276 ghClient := getRESTClient(t)
277 user, _, err := ghClient.Users.Get(context.Background(), "")
278 require.NoError(t, err, "expected to get user successfully")
279 require.Equal(t, trimmedContent.Login, *user.Login, "expected login to match")
280
281}
282
283func TestToolsets(t *testing.T) {
284 t.Parallel()

Callers

nothing calls this directly

Calls 2

setupMCPClientFunction · 0.85
getRESTClientFunction · 0.85

Tested by

no test coverage detected