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

Function Test_ActionsGetJobLogs_FailedJobs

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

Source from the content-addressed store, hash-verified

584}
585
586func Test_ActionsGetJobLogs_FailedJobs(t *testing.T) {
587 toolDef := ActionsGetJobLogs(translations.NullTranslationHelper)
588
589 t.Run("successful failed jobs logs", func(t *testing.T) {
590 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
591 GetReposActionsRunsJobsByOwnerByRepoByRunID: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
592 jobs := &github.Jobs{
593 TotalCount: github.Ptr(3),
594 Jobs: []*github.WorkflowJob{
595 {
596 ID: github.Ptr(int64(1)),
597 Name: github.Ptr("test-job-1"),
598 Conclusion: github.Ptr("success"),
599 },
600 {
601 ID: github.Ptr(int64(2)),
602 Name: github.Ptr("test-job-2"),
603 Conclusion: github.Ptr("failure"),
604 },
605 {
606 ID: github.Ptr(int64(3)),
607 Name: github.Ptr("test-job-3"),
608 Conclusion: github.Ptr("failure"),
609 },
610 },
611 }
612 w.WriteHeader(http.StatusOK)
613 _ = json.NewEncoder(w).Encode(jobs)
614 }),
615 GetReposActionsJobsLogsByOwnerByRepoByJobID: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
616 w.Header().Set("Location", "https://github.com/logs/job/"+r.URL.Path[len(r.URL.Path)-1:])
617 w.WriteHeader(http.StatusFound)
618 }),
619 })
620
621 client := mustNewGHClient(t, mockedClient)
622 deps := BaseDeps{
623 Client: client,
624 ContentWindowSize: 5000,
625 }
626 handler := toolDef.Handler(deps)
627
628 request := createMCPRequest(map[string]any{
629 "owner": "owner",
630 "repo": "repo",
631 "run_id": float64(456),
632 "failed_only": true,
633 })
634 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
635
636 require.NoError(t, err)
637 require.False(t, result.IsError)
638
639 textContent := getTextResult(t, result)
640 var response map[string]any
641 err = json.Unmarshal([]byte(textContent.Text), &response)
642 require.NoError(t, err)
643 assert.Equal(t, float64(456), response["run_id"])

Callers

nothing calls this directly

Calls 9

ActionsGetJobLogsFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
WriteHeaderMethod · 0.80
HeaderMethod · 0.80
HandlerMethod · 0.45

Tested by

no test coverage detected