@@ -15,14 +15,17 @@ import (
1515 "github.com/github/github-mcp-server/internal/profiler"
1616 "github.com/github/github-mcp-server/internal/toolsnaps"
1717 buffer "github.com/github/github-mcp-server/pkg/buffer"
18- mock "github.com/github/github-mcp-server/pkg/github/testmock"
1918 "github.com/github/github-mcp-server/pkg/translations"
2019 "github.com/google/go-github/v79/github"
2120 "github.com/google/jsonschema-go/jsonschema"
2221 "github.com/stretchr/testify/assert"
2322 "github.com/stretchr/testify/require"
2423)
2524
25+ func newMockedHTTPClient (handlers map [string ]http.HandlerFunc ) * http.Client {
26+ return MockHTTPClientWithHandlers (handlers )
27+ }
28+
2629func Test_ListWorkflows (t * testing.T ) {
2730 // Verify tool definition once
2831 toolDef := ListWorkflows (translations .NullTranslationHelper )
@@ -1394,17 +1397,11 @@ func Test_RerunFailedJobs(t *testing.T) {
13941397 }{
13951398 {
13961399 name : "successful rerun of failed jobs" ,
1397- mockedClient : mock .NewMockedHTTPClient (
1398- mock .WithRequestMatchHandler (
1399- mock.EndpointPattern {
1400- Pattern : "/repos/owner/repo/actions/runs/12345/rerun-failed-jobs" ,
1401- Method : "POST" ,
1402- },
1403- http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
1404- w .WriteHeader (http .StatusCreated )
1405- }),
1406- ),
1407- ),
1400+ mockedClient : newMockedHTTPClient (map [string ]http.HandlerFunc {
1401+ "POST /repos/owner/repo/actions/runs/12345/rerun-failed-jobs" : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
1402+ w .WriteHeader (http .StatusCreated )
1403+ }),
1404+ }),
14081405 requestArgs : map [string ]any {
14091406 "owner" : "owner" ,
14101407 "repo" : "repo" ,
@@ -1414,7 +1411,7 @@ func Test_RerunFailedJobs(t *testing.T) {
14141411 },
14151412 {
14161413 name : "missing required parameter run_id" ,
1417- mockedClient : mock . NewMockedHTTPClient ( ),
1414+ mockedClient : MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} ),
14181415 requestArgs : map [string ]any {
14191416 "owner" : "owner" ,
14201417 "repo" : "repo" ,
@@ -1486,7 +1483,7 @@ func Test_RerunWorkflowRun_Behavioral(t *testing.T) {
14861483 },
14871484 {
14881485 name : "missing required parameter run_id" ,
1489- mockedClient : mock . NewMockedHTTPClient ( ),
1486+ mockedClient : MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} ),
14901487 requestArgs : map [string ]any {
14911488 "owner" : "owner" ,
14921489 "repo" : "repo" ,
@@ -1573,7 +1570,7 @@ func Test_ListWorkflowRuns_Behavioral(t *testing.T) {
15731570 },
15741571 {
15751572 name : "missing required parameter workflow_id" ,
1576- mockedClient : mock . NewMockedHTTPClient ( ),
1573+ mockedClient : MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} ),
15771574 requestArgs : map [string ]any {
15781575 "owner" : "owner" ,
15791576 "repo" : "repo" ,
@@ -1649,7 +1646,7 @@ func Test_GetWorkflowRun_Behavioral(t *testing.T) {
16491646 },
16501647 {
16511648 name : "missing required parameter run_id" ,
1652- mockedClient : mock . NewMockedHTTPClient ( ),
1649+ mockedClient : MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} ),
16531650 requestArgs : map [string ]any {
16541651 "owner" : "owner" ,
16551652 "repo" : "repo" ,
@@ -1719,7 +1716,7 @@ func Test_GetWorkflowRunLogs_Behavioral(t *testing.T) {
17191716 },
17201717 {
17211718 name : "missing required parameter run_id" ,
1722- mockedClient : mock . NewMockedHTTPClient ( ),
1719+ mockedClient : MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} ),
17231720 requestArgs : map [string ]any {
17241721 "owner" : "owner" ,
17251722 "repo" : "repo" ,
@@ -1806,7 +1803,7 @@ func Test_ListWorkflowJobs_Behavioral(t *testing.T) {
18061803 },
18071804 {
18081805 name : "missing required parameter run_id" ,
1809- mockedClient : mock . NewMockedHTTPClient ( ),
1806+ mockedClient : MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} ),
18101807 requestArgs : map [string ]any {
18111808 "owner" : "owner" ,
18121809 "repo" : "repo" ,
@@ -1908,7 +1905,7 @@ func Test_ActionsList_ListWorkflows(t *testing.T) {
19081905 },
19091906 {
19101907 name : "missing required parameter method" ,
1911- mockedClient : mock . NewMockedHTTPClient ( ),
1908+ mockedClient : MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} ),
19121909 requestArgs : map [string ]any {
19131910 "owner" : "owner" ,
19141911 "repo" : "repo" ,
@@ -2204,7 +2201,7 @@ func Test_ActionsRunTrigger_RunWorkflow(t *testing.T) {
22042201 },
22052202 {
22062203 name : "missing required parameter workflow_id" ,
2207- mockedClient : mock . NewMockedHTTPClient ( ),
2204+ mockedClient : MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} ),
22082205 requestArgs : map [string ]any {
22092206 "method" : "run_workflow" ,
22102207 "owner" : "owner" ,
@@ -2216,7 +2213,7 @@ func Test_ActionsRunTrigger_RunWorkflow(t *testing.T) {
22162213 },
22172214 {
22182215 name : "missing required parameter ref" ,
2219- mockedClient : mock . NewMockedHTTPClient ( ),
2216+ mockedClient : MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} ),
22202217 requestArgs : map [string ]any {
22212218 "method" : "run_workflow" ,
22222219 "owner" : "owner" ,
@@ -2332,7 +2329,7 @@ func Test_ActionsRunTrigger_CancelWorkflowRun(t *testing.T) {
23322329 })
23332330
23342331 t .Run ("missing run_id for non-run_workflow methods" , func (t * testing.T ) {
2335- mockedClient := mock . NewMockedHTTPClient ( )
2332+ mockedClient := MockHTTPClientWithHandlers ( map [ string ]http. HandlerFunc {} )
23362333
23372334 client := github .NewClient (mockedClient )
23382335 deps := BaseDeps {
0 commit comments