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

Function Test_ActionsList_ListWorkflowRuns

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

Source from the content-addressed store, hash-verified

115}
116
117func Test_ActionsList_ListWorkflowRuns(t *testing.T) {
118 toolDef := ActionsList(translations.NullTranslationHelper)
119
120 t.Run("successful workflow runs list", func(t *testing.T) {
121 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
122 GetReposActionsWorkflowsRunsByOwnerByRepoByWorkflowID: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
123 runs := &github.WorkflowRuns{
124 TotalCount: github.Ptr(1),
125 WorkflowRuns: []*github.WorkflowRun{
126 {
127 ID: github.Ptr(int64(123)),
128 Name: github.Ptr("CI"),
129 Status: github.Ptr("completed"),
130 Conclusion: github.Ptr("success"),
131 },
132 },
133 }
134 w.WriteHeader(http.StatusOK)
135 _ = json.NewEncoder(w).Encode(runs)
136 }),
137 })
138
139 client := mustNewGHClient(t, mockedClient)
140 deps := BaseDeps{
141 Client: client,
142 }
143 handler := toolDef.Handler(deps)
144
145 request := createMCPRequest(map[string]any{
146 "method": "list_workflow_runs",
147 "owner": "owner",
148 "repo": "repo",
149 "resource_id": "ci.yml",
150 })
151 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
152
153 require.NoError(t, err)
154 require.False(t, result.IsError)
155
156 textContent := getTextResult(t, result)
157 var response github.WorkflowRuns
158 err = json.Unmarshal([]byte(textContent.Text), &response)
159 require.NoError(t, err)
160 assert.NotNil(t, response.TotalCount)
161 })
162
163 t.Run("list all workflow runs without resource_id", func(t *testing.T) {
164 mockedClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
165 GetReposActionsRunsByOwnerByRepo: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
166 runs := &github.WorkflowRuns{
167 TotalCount: github.Ptr(2),
168 WorkflowRuns: []*github.WorkflowRun{
169 {
170 ID: github.Ptr(int64(123)),
171 Name: github.Ptr("CI"),
172 Status: github.Ptr("completed"),
173 Conclusion: github.Ptr("success"),
174 },

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