(t *testing.T)
| 328 | } |
| 329 | |
| 330 | func Test_ActionsRunTrigger_RunWorkflow(t *testing.T) { |
| 331 | toolDef := ActionsRunTrigger(translations.NullTranslationHelper) |
| 332 | |
| 333 | tests := []struct { |
| 334 | name string |
| 335 | mockedClient *http.Client |
| 336 | requestArgs map[string]any |
| 337 | expectError bool |
| 338 | expectedErrMsg string |
| 339 | }{ |
| 340 | { |
| 341 | name: "successful workflow run", |
| 342 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 343 | PostReposActionsWorkflowsDispatchesByOwnerByRepoByWorkflowID: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 344 | w.WriteHeader(http.StatusNoContent) |
| 345 | }), |
| 346 | }), |
| 347 | requestArgs: map[string]any{ |
| 348 | "method": "run_workflow", |
| 349 | "owner": "owner", |
| 350 | "repo": "repo", |
| 351 | "workflow_id": "12345", |
| 352 | "ref": "main", |
| 353 | }, |
| 354 | expectError: false, |
| 355 | }, |
| 356 | { |
| 357 | name: "missing required parameter workflow_id", |
| 358 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{}), |
| 359 | requestArgs: map[string]any{ |
| 360 | "method": "run_workflow", |
| 361 | "owner": "owner", |
| 362 | "repo": "repo", |
| 363 | "ref": "main", |
| 364 | }, |
| 365 | expectError: true, |
| 366 | expectedErrMsg: "workflow_id is required for run_workflow action", |
| 367 | }, |
| 368 | { |
| 369 | name: "missing required parameter ref", |
| 370 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{}), |
| 371 | requestArgs: map[string]any{ |
| 372 | "method": "run_workflow", |
| 373 | "owner": "owner", |
| 374 | "repo": "repo", |
| 375 | "workflow_id": "12345", |
| 376 | }, |
| 377 | expectError: true, |
| 378 | expectedErrMsg: "ref is required for run_workflow action", |
| 379 | }, |
| 380 | { |
| 381 | name: "successful workflow run with inputs", |
| 382 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 383 | PostReposActionsWorkflowsDispatchesByOwnerByRepoByWorkflowID: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 384 | w.WriteHeader(http.StatusNoContent) |
| 385 | }), |
| 386 | }), |
| 387 | requestArgs: map[string]any{ |
nothing calls this directly
no test coverage detected