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

Function Test_ProjectsGet_GetProjectField

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

Source from the content-addressed store, hash-verified

702}
703
704func Test_ProjectsGet_GetProjectField(t *testing.T) {
705 toolDef := ProjectsGet(translations.NullTranslationHelper)
706
707 field := map[string]any{"id": 101, "name": "Status", "data_type": "single_select"}
708
709 t.Run("success organization", func(t *testing.T) {
710 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
711 GetOrgsProjectsV2FieldsByProjectByFieldID: mockResponse(t, http.StatusOK, field),
712 })
713
714 client := mustNewGHClient(t, mockedClient)
715 deps := BaseDeps{
716 Client: client,
717 }
718 handler := toolDef.Handler(deps)
719 request := createMCPRequest(map[string]any{
720 "method": "get_project_field",
721 "owner": "octo-org",
722 "owner_type": "org",
723 "project_number": float64(1),
724 "field_id": float64(101),
725 })
726 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
727
728 require.NoError(t, err)
729 require.False(t, result.IsError)
730
731 textContent := getTextResult(t, result)
732 var response map[string]any
733 err = json.Unmarshal([]byte(textContent.Text), &response)
734 require.NoError(t, err)
735 assert.NotNil(t, response["id"])
736 })
737
738 t.Run("missing field_id", func(t *testing.T) {
739 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{})
740 client := mustNewGHClient(t, mockedClient)
741 deps := BaseDeps{
742 Client: client,
743 }
744 handler := toolDef.Handler(deps)
745 request := createMCPRequest(map[string]any{
746 "method": "get_project_field",
747 "owner": "octo-org",
748 "owner_type": "org",
749 "project_number": float64(1),
750 })
751 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
752
753 require.NoError(t, err)
754 require.True(t, result.IsError)
755 textContent := getTextResult(t, result)
756 assert.Contains(t, textContent.Text, "missing required parameter: field_id")
757 })
758}
759
760func Test_ProjectsGet_GetProjectItem(t *testing.T) {
761 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