MCPcopy
hub / github.com/github/github-mcp-server / Test_ActionsRunTrigger_RunWorkflow

Function Test_ActionsRunTrigger_RunWorkflow

pkg/github/actions_test.go:330–440  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

328}
329
330func 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{

Callers

nothing calls this directly

Calls 8

ActionsRunTriggerFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
WriteHeaderMethod · 0.80
HandlerMethod · 0.45

Tested by

no test coverage detected