(t *testing.T)
| 115 | } |
| 116 | |
| 117 | func Test_ActionsList_ListWorkflowRuns(t *testing.T) { |
| 118 | toolDef := ActionsList(translations.NullTranslationHelper) |
| 119 | |
| 120 | t.Run("successful workflow runs list", func(t *testing.T) { |
| 121 | mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 122 | GetReposActionsWorkflowsRunsByOwnerByRepoByWorkflowID: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 123 | runs := &github.WorkflowRuns{ |
| 124 | TotalCount: github.Ptr(1), |
| 125 | WorkflowRuns: []*github.WorkflowRun{ |
| 126 | { |
| 127 | ID: github.Ptr(int64(123)), |
| 128 | Name: github.Ptr("CI"), |
| 129 | Status: github.Ptr("completed"), |
| 130 | Conclusion: github.Ptr("success"), |
| 131 | }, |
| 132 | }, |
| 133 | } |
| 134 | w.WriteHeader(http.StatusOK) |
| 135 | _ = json.NewEncoder(w).Encode(runs) |
| 136 | }), |
| 137 | }) |
| 138 | |
| 139 | client := mustNewGHClient(t, mockedClient) |
| 140 | deps := BaseDeps{ |
| 141 | Client: client, |
| 142 | } |
| 143 | handler := toolDef.Handler(deps) |
| 144 | |
| 145 | request := createMCPRequest(map[string]any{ |
| 146 | "method": "list_workflow_runs", |
| 147 | "owner": "owner", |
| 148 | "repo": "repo", |
| 149 | "resource_id": "ci.yml", |
| 150 | }) |
| 151 | result, err := handler(ContextWithDeps(context.Background(), deps), &request) |
| 152 | |
| 153 | require.NoError(t, err) |
| 154 | require.False(t, result.IsError) |
| 155 | |
| 156 | textContent := getTextResult(t, result) |
| 157 | var response github.WorkflowRuns |
| 158 | err = json.Unmarshal([]byte(textContent.Text), &response) |
| 159 | require.NoError(t, err) |
| 160 | assert.NotNil(t, response.TotalCount) |
| 161 | }) |
| 162 | |
| 163 | t.Run("list all workflow runs without resource_id", func(t *testing.T) { |
| 164 | mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 165 | GetReposActionsRunsByOwnerByRepo: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 166 | runs := &github.WorkflowRuns{ |
| 167 | TotalCount: github.Ptr(2), |
| 168 | WorkflowRuns: []*github.WorkflowRun{ |
| 169 | { |
| 170 | ID: github.Ptr(int64(123)), |
| 171 | Name: github.Ptr("CI"), |
| 172 | Status: github.Ptr("completed"), |
| 173 | Conclusion: github.Ptr("success"), |
| 174 | }, |
nothing calls this directly
no test coverage detected