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

Function Test_ActionsGet_GetWorkflowRun

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

Source from the content-addressed store, hash-verified

268}
269
270func Test_ActionsGet_GetWorkflowRun(t *testing.T) {
271 toolDef := ActionsGet(translations.NullTranslationHelper)
272
273 t.Run("successful workflow run get", func(t *testing.T) {
274 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
275 GetReposActionsRunsByOwnerByRepoByRunID: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
276 run := &github.WorkflowRun{
277 ID: github.Ptr(int64(12345)),
278 Name: github.Ptr("CI"),
279 Status: github.Ptr("completed"),
280 Conclusion: github.Ptr("success"),
281 }
282 w.WriteHeader(http.StatusOK)
283 _ = json.NewEncoder(w).Encode(run)
284 }),
285 })
286
287 client := mustNewGHClient(t, mockedClient)
288 deps := BaseDeps{
289 Client: client,
290 }
291 handler := toolDef.Handler(deps)
292
293 request := createMCPRequest(map[string]any{
294 "method": "get_workflow_run",
295 "owner": "owner",
296 "repo": "repo",
297 "resource_id": "12345",
298 })
299 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
300
301 require.NoError(t, err)
302 require.False(t, result.IsError)
303
304 textContent := getTextResult(t, result)
305 var response github.WorkflowRun
306 err = json.Unmarshal([]byte(textContent.Text), &response)
307 require.NoError(t, err)
308 assert.NotNil(t, response.ID)
309 assert.Equal(t, int64(12345), *response.ID)
310 })
311}
312
313func Test_ActionsRunTrigger(t *testing.T) {
314 // Verify tool definition once

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