MCPcopy
hub / github.com/github/github-mcp-server / Test_ActionsGet_GetWorkflow

Function Test_ActionsGet_GetWorkflow

pkg/github/actions_test.go:227–268  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func Test_ActionsGet_GetWorkflow(t *testing.T) {
228 toolDef := ActionsGet(translations.NullTranslationHelper)
229
230 t.Run("successful workflow get", func(t *testing.T) {
231 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
232 GetReposActionsWorkflowsByOwnerByRepoByWorkflowID: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
233 workflow := &github.Workflow{
234 ID: github.Ptr(int64(1)),
235 Name: github.Ptr("CI"),
236 Path: github.Ptr(".github/workflows/ci.yml"),
237 State: github.Ptr("active"),
238 }
239 w.WriteHeader(http.StatusOK)
240 _ = json.NewEncoder(w).Encode(workflow)
241 }),
242 })
243
244 client := mustNewGHClient(t, mockedClient)
245 deps := BaseDeps{
246 Client: client,
247 }
248 handler := toolDef.Handler(deps)
249
250 request := createMCPRequest(map[string]any{
251 "method": "get_workflow",
252 "owner": "owner",
253 "repo": "repo",
254 "resource_id": "ci.yml",
255 })
256 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
257
258 require.NoError(t, err)
259 require.False(t, result.IsError)
260
261 textContent := getTextResult(t, result)
262 var response github.Workflow
263 err = json.Unmarshal([]byte(textContent.Text), &response)
264 require.NoError(t, err)
265 assert.NotNil(t, response.ID)
266 assert.Equal(t, "CI", *response.Name)
267 })
268}
269
270func Test_ActionsGet_GetWorkflowRun(t *testing.T) {
271 toolDef := ActionsGet(translations.NullTranslationHelper)

Callers

nothing calls this directly

Calls 8

ActionsGetFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
WriteHeaderMethod · 0.80
HandlerMethod · 0.45

Tested by

no test coverage detected