Skip to content

Commit 5da1d0a

Browse files
committed
.
1 parent a09d976 commit 5da1d0a

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

pkg/github/issues_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func Test_GetIssue(t *testing.T) {
2323
// Verify tool definition once
2424
mockClient := github.NewClient(nil)
2525
defaultGQLClient := githubv4.NewClient(nil)
26-
tool, _ := IssueRead(stubGetClientFn(mockClient), stubGetGQLClientFn(defaultGQLClient), stubRepoAccessCache(defaultGQLClient), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
26+
tool, _ := IssueRead(stubGetClientFn(mockClient), stubGetGQLClientFn(defaultGQLClient), stubRepoAccessCache(defaultGQLClient, 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
2727
require.NoError(t, toolsnaps.Test(tool.Name, tool))
2828

2929
assert.Equal(t, "issue_read", tool.Name)
@@ -212,7 +212,7 @@ func Test_GetIssue(t *testing.T) {
212212
}
213213

214214
flags := stubFeatureFlags(map[string]bool{"lockdown-mode": tc.lockdownEnabled})
215-
_, handler := IssueRead(stubGetClientFn(client), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient), translations.NullTranslationHelper, flags)
215+
_, handler := IssueRead(stubGetClientFn(client), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient, 15*time.Minute), translations.NullTranslationHelper, flags)
216216

217217
request := createMCPRequest(tc.requestArgs)
218218
result, err := handler(context.Background(), request)
@@ -1710,7 +1710,7 @@ func Test_GetIssueComments(t *testing.T) {
17101710
// Verify tool definition once
17111711
mockClient := github.NewClient(nil)
17121712
gqlClient := githubv4.NewClient(nil)
1713-
tool, _ := IssueRead(stubGetClientFn(mockClient), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1713+
tool, _ := IssueRead(stubGetClientFn(mockClient), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient, 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
17141714
require.NoError(t, toolsnaps.Test(tool.Name, tool))
17151715

17161716
assert.Equal(t, "issue_read", tool.Name)
@@ -1816,7 +1816,7 @@ func Test_GetIssueComments(t *testing.T) {
18161816
// Setup client with mock
18171817
client := github.NewClient(tc.mockedClient)
18181818
gqlClient := githubv4.NewClient(nil)
1819-
_, handler := IssueRead(stubGetClientFn(client), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1819+
_, handler := IssueRead(stubGetClientFn(client), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient, 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
18201820

18211821
// Create call request
18221822
request := createMCPRequest(tc.requestArgs)
@@ -1853,7 +1853,7 @@ func Test_GetIssueLabels(t *testing.T) {
18531853
// Verify tool definition
18541854
mockGQClient := githubv4.NewClient(nil)
18551855
mockClient := github.NewClient(nil)
1856-
tool, _ := IssueRead(stubGetClientFn(mockClient), stubGetGQLClientFn(mockGQClient), stubRepoAccessCache(mockGQClient), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1856+
tool, _ := IssueRead(stubGetClientFn(mockClient), stubGetGQLClientFn(mockGQClient), stubRepoAccessCache(mockGQClient, 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
18571857
require.NoError(t, toolsnaps.Test(tool.Name, tool))
18581858

18591859
assert.Equal(t, "issue_read", tool.Name)
@@ -1928,7 +1928,7 @@ func Test_GetIssueLabels(t *testing.T) {
19281928
t.Run(tc.name, func(t *testing.T) {
19291929
gqlClient := githubv4.NewClient(tc.mockedClient)
19301930
client := github.NewClient(nil)
1931-
_, handler := IssueRead(stubGetClientFn(client), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1931+
_, handler := IssueRead(stubGetClientFn(client), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient, 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
19321932

19331933
request := createMCPRequest(tc.requestArgs)
19341934
result, err := handler(context.Background(), request)
@@ -2619,7 +2619,7 @@ func Test_GetSubIssues(t *testing.T) {
26192619
// Verify tool definition once
26202620
mockClient := github.NewClient(nil)
26212621
gqlClient := githubv4.NewClient(nil)
2622-
tool, _ := IssueRead(stubGetClientFn(mockClient), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
2622+
tool, _ := IssueRead(stubGetClientFn(mockClient), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient, 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
26232623
require.NoError(t, toolsnaps.Test(tool.Name, tool))
26242624

26252625
assert.Equal(t, "issue_read", tool.Name)
@@ -2816,7 +2816,7 @@ func Test_GetSubIssues(t *testing.T) {
28162816
// Setup client with mock
28172817
client := github.NewClient(tc.mockedClient)
28182818
gqlClient := githubv4.NewClient(nil)
2819-
_, handler := IssueRead(stubGetClientFn(client), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
2819+
_, handler := IssueRead(stubGetClientFn(client), stubGetGQLClientFn(gqlClient), stubRepoAccessCache(gqlClient, 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
28202820

28212821
// Create call request
28222822
request := createMCPRequest(tc.requestArgs)

pkg/github/pullrequests_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
func Test_GetPullRequest(t *testing.T) {
2222
// Verify tool definition once
2323
mockClient := github.NewClient(nil)
24-
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
24+
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
2525
require.NoError(t, toolsnaps.Test(tool.Name, tool))
2626

2727
assert.Equal(t, "pull_request_read", tool.Name)
@@ -102,7 +102,7 @@ func Test_GetPullRequest(t *testing.T) {
102102
t.Run(tc.name, func(t *testing.T) {
103103
// Setup client with mock
104104
client := github.NewClient(tc.mockedClient)
105-
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
105+
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
106106

107107
// Create call request
108108
request := createMCPRequest(tc.requestArgs)
@@ -1133,7 +1133,7 @@ func Test_SearchPullRequests(t *testing.T) {
11331133
func Test_GetPullRequestFiles(t *testing.T) {
11341134
// Verify tool definition once
11351135
mockClient := github.NewClient(nil)
1136-
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1136+
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
11371137
require.NoError(t, toolsnaps.Test(tool.Name, tool))
11381138

11391139
assert.Equal(t, "pull_request_read", tool.Name)
@@ -1236,7 +1236,7 @@ func Test_GetPullRequestFiles(t *testing.T) {
12361236
t.Run(tc.name, func(t *testing.T) {
12371237
// Setup client with mock
12381238
client := github.NewClient(tc.mockedClient)
1239-
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1239+
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
12401240

12411241
// Create call request
12421242
request := createMCPRequest(tc.requestArgs)
@@ -1277,7 +1277,7 @@ func Test_GetPullRequestFiles(t *testing.T) {
12771277
func Test_GetPullRequestStatus(t *testing.T) {
12781278
// Verify tool definition once
12791279
mockClient := github.NewClient(nil)
1280-
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1280+
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
12811281
require.NoError(t, toolsnaps.Test(tool.Name, tool))
12821282

12831283
assert.Equal(t, "pull_request_read", tool.Name)
@@ -1404,7 +1404,7 @@ func Test_GetPullRequestStatus(t *testing.T) {
14041404
t.Run(tc.name, func(t *testing.T) {
14051405
// Setup client with mock
14061406
client := github.NewClient(tc.mockedClient)
1407-
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1407+
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
14081408

14091409
// Create call request
14101410
request := createMCPRequest(tc.requestArgs)
@@ -1566,7 +1566,7 @@ func Test_UpdatePullRequestBranch(t *testing.T) {
15661566
func Test_GetPullRequestComments(t *testing.T) {
15671567
// Verify tool definition once
15681568
mockClient := github.NewClient(nil)
1569-
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1569+
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
15701570
require.NoError(t, toolsnaps.Test(tool.Name, tool))
15711571

15721572
assert.Equal(t, "pull_request_read", tool.Name)
@@ -1658,7 +1658,7 @@ func Test_GetPullRequestComments(t *testing.T) {
16581658
t.Run(tc.name, func(t *testing.T) {
16591659
// Setup client with mock
16601660
client := github.NewClient(tc.mockedClient)
1661-
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1661+
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
16621662

16631663
// Create call request
16641664
request := createMCPRequest(tc.requestArgs)
@@ -1700,7 +1700,7 @@ func Test_GetPullRequestComments(t *testing.T) {
17001700
func Test_GetPullRequestReviews(t *testing.T) {
17011701
// Verify tool definition once
17021702
mockClient := github.NewClient(nil)
1703-
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1703+
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
17041704
require.NoError(t, toolsnaps.Test(tool.Name, tool))
17051705

17061706
assert.Equal(t, "pull_request_read", tool.Name)
@@ -1788,7 +1788,7 @@ func Test_GetPullRequestReviews(t *testing.T) {
17881788
t.Run(tc.name, func(t *testing.T) {
17891789
// Setup client with mock
17901790
client := github.NewClient(tc.mockedClient)
1791-
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
1791+
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
17921792

17931793
// Create call request
17941794
request := createMCPRequest(tc.requestArgs)
@@ -2789,7 +2789,7 @@ func TestGetPullRequestDiff(t *testing.T) {
27892789

27902790
// Verify tool definition once
27912791
mockClient := github.NewClient(nil)
2792-
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
2792+
tool, _ := PullRequestRead(stubGetClientFn(mockClient), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
27932793
require.NoError(t, toolsnaps.Test(tool.Name, tool))
27942794

27952795
assert.Equal(t, "pull_request_read", tool.Name)
@@ -2847,7 +2847,7 @@ index 5d6e7b2..8a4f5c3 100644
28472847

28482848
// Setup client with mock
28492849
client := github.NewClient(tc.mockedClient)
2850-
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil)), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
2850+
_, handler := PullRequestRead(stubGetClientFn(client), stubRepoAccessCache(githubv4.NewClient(nil), 5*time.Minute), translations.NullTranslationHelper, stubFeatureFlags(map[string]bool{"lockdown-mode": false}))
28512851

28522852
// Create call request
28532853
request := createMCPRequest(tc.requestArgs)

pkg/github/server_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net/http"
99
"testing"
10+
"time"
1011

1112
"github.com/github/github-mcp-server/pkg/lockdown"
1213
"github.com/github/github-mcp-server/pkg/raw"
@@ -39,8 +40,8 @@ func stubGetGQLClientFn(client *githubv4.Client) GetGQLClientFn {
3940
}
4041
}
4142

42-
func stubRepoAccessCache(client *githubv4.Client) *lockdown.RepoAccessCache {
43-
return lockdown.GetInstance(client)
43+
func stubRepoAccessCache(client *githubv4.Client, ttl time.Duration) *lockdown.RepoAccessCache {
44+
return lockdown.GetInstance(client, lockdown.WithTTL(ttl))
4445
}
4546

4647
func stubFeatureFlags(enabledFlags map[string]bool) FeatureFlags {

0 commit comments

Comments
 (0)