Skip to content

Commit b966807

Browse files
committed
add test cases for valid and invalid inputs
1 parent 039808a commit b966807

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

pkg/github/actions_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,37 @@ func Test_ActionsRunTrigger_RunWorkflow(t *testing.T) {
377377
expectError: true,
378378
expectedErrMsg: "ref is required for run_workflow action",
379379
},
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{
388+
"method": "run_workflow",
389+
"owner": "owner",
390+
"repo": "repo",
391+
"workflow_id": "12345",
392+
"ref": "main",
393+
"inputs": map[string]any{"FIELD1": "value1", "FIELD2": "value2"},
394+
},
395+
expectError: false,
396+
},
397+
{
398+
name: "invalid inputs type returns error",
399+
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{}),
400+
requestArgs: map[string]any{
401+
"method": "run_workflow",
402+
"owner": "owner",
403+
"repo": "repo",
404+
"workflow_id": "12345",
405+
"ref": "main",
406+
"inputs": "not a map",
407+
},
408+
expectError: true,
409+
expectedErrMsg: "parameter inputs is not of type map[string]interface {}, is string",
410+
},
380411
}
381412

382413
for _, tc := range tests {

0 commit comments

Comments
 (0)