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

Function Test_ActionsList_ListWorkflows

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

Source from the content-addressed store, hash-verified

31}
32
33func 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{

Callers

nothing calls this directly

Calls 8

ActionsListFunction · 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