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

Function Test_ProjectsGet_GetProject

pkg/github/projects_test.go:576–629  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

574}
575
576func Test_ProjectsGet_GetProject(t *testing.T) {
577 toolDef := ProjectsGet(translations.NullTranslationHelper)
578
579 project := map[string]any{"id": 123, "title": "Project Title"}
580
581 t.Run("success organization", func(t *testing.T) {
582 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
583 GetOrgsProjectsV2ByProject: mockResponse(t, http.StatusOK, project),
584 })
585
586 client := mustNewGHClient(t, mockedClient)
587 deps := BaseDeps{
588 Client: client,
589 }
590 handler := toolDef.Handler(deps)
591 request := createMCPRequest(map[string]any{
592 "method": "get_project",
593 "owner": "octo-org",
594 "owner_type": "org",
595 "project_number": float64(1),
596 })
597 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
598
599 require.NoError(t, err)
600 require.False(t, result.IsError)
601
602 textContent := getTextResult(t, result)
603 var response map[string]any
604 err = json.Unmarshal([]byte(textContent.Text), &response)
605 require.NoError(t, err)
606 assert.NotNil(t, response["id"])
607 })
608
609 t.Run("unknown method", func(t *testing.T) {
610 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{})
611 client := mustNewGHClient(t, mockedClient)
612 deps := BaseDeps{
613 Client: client,
614 }
615 handler := toolDef.Handler(deps)
616 request := createMCPRequest(map[string]any{
617 "method": "unknown_method",
618 "owner": "octo-org",
619 "owner_type": "org",
620 "project_number": float64(1),
621 })
622 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
623
624 require.NoError(t, err)
625 require.True(t, result.IsError)
626 textContent := getTextResult(t, result)
627 assert.Contains(t, textContent.Text, "unknown method: unknown_method")
628 })
629}
630
631func Test_ProjectsGet_IFC_InsidersMode(t *testing.T) {
632 toolDef := ProjectsGet(translations.NullTranslationHelper)

Callers

nothing calls this directly

Calls 8

ProjectsGetFunction · 0.85
mockResponseFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
HandlerMethod · 0.45

Tested by

no test coverage detected