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

Function Test_ActionsGetJobLogs_SingleJob

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

Source from the content-addressed store, hash-verified

546}
547
548func Test_ActionsGetJobLogs_SingleJob(t *testing.T) {
549 toolDef := ActionsGetJobLogs(translations.NullTranslationHelper)
550
551 t.Run("successful single job logs with URL", func(t *testing.T) {
552 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
553 GetReposActionsJobsLogsByOwnerByRepoByJobID: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
554 w.Header().Set("Location", "https://github.com/logs/job/123")
555 w.WriteHeader(http.StatusFound)
556 }),
557 })
558
559 client := mustNewGHClient(t, mockedClient)
560 deps := BaseDeps{
561 Client: client,
562 ContentWindowSize: 5000,
563 }
564 handler := toolDef.Handler(deps)
565
566 request := createMCPRequest(map[string]any{
567 "owner": "owner",
568 "repo": "repo",
569 "job_id": float64(123),
570 })
571 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
572
573 require.NoError(t, err)
574 require.False(t, result.IsError)
575
576 textContent := getTextResult(t, result)
577 var response map[string]any
578 err = json.Unmarshal([]byte(textContent.Text), &response)
579 require.NoError(t, err)
580 assert.Equal(t, float64(123), response["job_id"])
581 assert.Contains(t, response, "logs_url")
582 assert.Equal(t, "Job logs are available for download", response["message"])
583 })
584}
585
586func Test_ActionsGetJobLogs_FailedJobs(t *testing.T) {
587 toolDef := ActionsGetJobLogs(translations.NullTranslationHelper)

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected