(t *testing.T)
| 584 | } |
| 585 | |
| 586 | func 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"]) |
nothing calls this directly
no test coverage detected