(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func Test_ActionsList_ListWorkflows(t *testing.T) { |
| 34 | toolDef := ActionsList(translations.NullTranslationHelper) |
| 35 | |
| 36 | tests := []struct { |
| 37 | name string |
| 38 | mockedClient *http.Client |
| 39 | requestArgs map[string]any |
| 40 | expectError bool |
| 41 | expectedErrMsg string |
| 42 | }{ |
| 43 | { |
| 44 | name: "successful workflow list", |
| 45 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 46 | GetReposActionsWorkflowsByOwnerByRepo: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 47 | workflows := &github.Workflows{ |
| 48 | TotalCount: github.Ptr(2), |
| 49 | Workflows: []*github.Workflow{ |
| 50 | { |
| 51 | ID: github.Ptr(int64(1)), |
| 52 | Name: github.Ptr("CI"), |
| 53 | Path: github.Ptr(".github/workflows/ci.yml"), |
| 54 | State: github.Ptr("active"), |
| 55 | }, |
| 56 | { |
| 57 | ID: github.Ptr(int64(2)), |
| 58 | Name: github.Ptr("Deploy"), |
| 59 | Path: github.Ptr(".github/workflows/deploy.yml"), |
| 60 | State: github.Ptr("active"), |
| 61 | }, |
| 62 | }, |
| 63 | } |
| 64 | w.WriteHeader(http.StatusOK) |
| 65 | _ = json.NewEncoder(w).Encode(workflows) |
| 66 | }), |
| 67 | }), |
| 68 | requestArgs: map[string]any{ |
| 69 | "method": "list_workflows", |
| 70 | "owner": "owner", |
| 71 | "repo": "repo", |
| 72 | }, |
| 73 | expectError: false, |
| 74 | }, |
| 75 | { |
| 76 | name: "missing required parameter method", |
| 77 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{}), |
| 78 | requestArgs: map[string]any{ |
| 79 | "owner": "owner", |
| 80 | "repo": "repo", |
| 81 | }, |
| 82 | expectError: true, |
| 83 | expectedErrMsg: "missing required parameter: method", |
| 84 | }, |
| 85 | } |
| 86 | |
| 87 | for _, tc := range tests { |
| 88 | t.Run(tc.name, func(t *testing.T) { |
| 89 | client := mustNewGHClient(t, tc.mockedClient) |
| 90 | deps := BaseDeps{ |
nothing calls this directly
no test coverage detected