Skip to content

Commit 04afa0b

Browse files
committed
Fixing flaky testss
1 parent 4b58040 commit 04afa0b

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

‎pkg/github/issue_artifacts_test.go‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"encoding/json"
66
"net/http"
77
"net/http/httptest"
8-
"net/url"
98
"strings"
109
"testing"
1110

1211
"github.com/github/github-mcp-server/v2/internal/toolsnaps"
1312
"github.com/github/github-mcp-server/v2/pkg/inventory"
1413
"github.com/github/github-mcp-server/v2/pkg/translations"
14+
gogithub "github.com/google/go-github/v92/github"
1515
"github.com/google/jsonschema-go/jsonschema"
1616
"github.com/modelcontextprotocol/go-sdk/mcp"
1717
"github.com/stretchr/testify/assert"
@@ -116,10 +116,11 @@ func TestIssueArtifactRequests(t *testing.T) {
116116
_, _ = w.Write([]byte(tc.result))
117117
}))
118118
defer server.Close()
119-
client := mustNewGHClient(t, server.Client())
120-
baseURL, err := url.Parse(server.URL + "/api/v3/")
119+
client, err := gogithub.NewClient(
120+
gogithub.WithHTTPClient(server.Client()),
121+
gogithub.WithEnterpriseURLs(server.URL+"/api/v3/", server.URL+"/api/uploads/"),
122+
)
121123
require.NoError(t, err)
122-
client.BaseURL = baseURL
123124
args := map[string]any{"owner": "o", "repo": "r", "issue_number": 12}
124125
for key, value := range tc.args {
125126
args[key] = value
@@ -222,10 +223,11 @@ func TestIssueArtifactFailures(t *testing.T) {
222223
_, _ = w.Write([]byte(`{"message":"artifact access failed"}`))
223224
}))
224225
defer server.Close()
225-
client := mustNewGHClient(t, server.Client())
226-
baseURL, err := url.Parse(server.URL + "/")
226+
client, err := gogithub.NewClient(
227+
gogithub.WithHTTPClient(server.Client()),
228+
gogithub.WithEnterpriseURLs(server.URL+"/", server.URL+"/"),
229+
)
227230
require.NoError(t, err)
228-
client.BaseURL = baseURL
229231
result := callArtifactTool(t, tool, BaseDeps{Client: client}, args)
230232
assert.True(t, result.IsError)
231233
assert.Contains(t, getTextResult(t, result).Text, "artifact")

0 commit comments

Comments
 (0)