99
1010"github.com/github/github-mcp-server/internal/githubv4mock"
1111"github.com/github/github-mcp-server/internal/toolsnaps"
12+ "github.com/github/github-mcp-server/pkg/lockdown"
1213"github.com/github/github-mcp-server/pkg/translations"
1314"github.com/google/go-github/v79/github"
1415"github.com/shurcooL/githubv4"
@@ -19,9 +20,14 @@ import (
1920)
2021
2122func Test_GetPullRequest (t * testing.T ) {
23+ // Initialize lockdown cache once for this test
24+ gqlClient := githubv4 .NewClient (nil )
25+ lockdown .ResetInstance ()
26+ lockdown .GetInstance (gqlClient ,lockdown .WithTTL (5 * time .Minute ))
27+
2228// Verify tool definition once
2329mockClient := github .NewClient (nil )
24- tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (githubv4 . NewClient ( nil ) ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
30+ tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (gqlClient ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
2531require .NoError (t ,toolsnaps .Test (tool .Name ,tool ))
2632
2733assert .Equal (t ,"pull_request_read" ,tool .Name )
@@ -1131,9 +1137,14 @@ func Test_SearchPullRequests(t *testing.T) {
11311137}
11321138
11331139func Test_GetPullRequestFiles (t * testing.T ) {
1140+ // Initialize lockdown cache once for this test
1141+ gqlClient := githubv4 .NewClient (nil )
1142+ lockdown .ResetInstance ()
1143+ lockdown .GetInstance (gqlClient ,lockdown .WithTTL (5 * time .Minute ))
1144+
11341145// Verify tool definition once
11351146mockClient := github .NewClient (nil )
1136- tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (githubv4 . NewClient ( nil ) ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
1147+ tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (gqlClient ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
11371148require .NoError (t ,toolsnaps .Test (tool .Name ,tool ))
11381149
11391150assert .Equal (t ,"pull_request_read" ,tool .Name )
@@ -1275,9 +1286,14 @@ func Test_GetPullRequestFiles(t *testing.T) {
12751286}
12761287
12771288func Test_GetPullRequestStatus (t * testing.T ) {
1289+ // Initialize lockdown cache once for this test
1290+ gqlClient := githubv4 .NewClient (nil )
1291+ lockdown .ResetInstance ()
1292+ lockdown .GetInstance (gqlClient ,lockdown .WithTTL (5 * time .Minute ))
1293+
12781294// Verify tool definition once
12791295mockClient := github .NewClient (nil )
1280- tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (githubv4 . NewClient ( nil ) ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
1296+ tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (gqlClient ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
12811297require .NoError (t ,toolsnaps .Test (tool .Name ,tool ))
12821298
12831299assert .Equal (t ,"pull_request_read" ,tool .Name )
@@ -1564,9 +1580,14 @@ func Test_UpdatePullRequestBranch(t *testing.T) {
15641580}
15651581
15661582func Test_GetPullRequestComments (t * testing.T ) {
1583+ // Initialize lockdown cache once for this test
1584+ gqlClient := githubv4 .NewClient (nil )
1585+ lockdown .ResetInstance ()
1586+ lockdown .GetInstance (gqlClient ,lockdown .WithTTL (5 * time .Minute ))
1587+
15671588// Verify tool definition once
15681589mockClient := github .NewClient (nil )
1569- tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (githubv4 . NewClient ( nil ) ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
1590+ tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (gqlClient ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
15701591require .NoError (t ,toolsnaps .Test (tool .Name ,tool ))
15711592
15721593assert .Equal (t ,"pull_request_read" ,tool .Name )
@@ -1698,9 +1719,14 @@ func Test_GetPullRequestComments(t *testing.T) {
16981719}
16991720
17001721func Test_GetPullRequestReviews (t * testing.T ) {
1722+ // Initialize lockdown cache once for this test
1723+ gqlClient := githubv4 .NewClient (nil )
1724+ lockdown .ResetInstance ()
1725+ lockdown .GetInstance (gqlClient ,lockdown .WithTTL (5 * time .Minute ))
1726+
17011727// Verify tool definition once
17021728mockClient := github .NewClient (nil )
1703- tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (githubv4 . NewClient ( nil ) ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
1729+ tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (gqlClient ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
17041730require .NoError (t ,toolsnaps .Test (tool .Name ,tool ))
17051731
17061732assert .Equal (t ,"pull_request_read" ,tool .Name )
@@ -2787,9 +2813,14 @@ func TestDeletePendingPullRequestReview(t *testing.T) {
27872813func TestGetPullRequestDiff (t * testing.T ) {
27882814t .Parallel ()
27892815
2816+ // Initialize lockdown cache once for this test
2817+ gqlClient := githubv4 .NewClient (nil )
2818+ lockdown .ResetInstance ()
2819+ lockdown .GetInstance (gqlClient ,lockdown .WithTTL (5 * time .Minute ))
2820+
27902821// Verify tool definition once
27912822mockClient := github .NewClient (nil )
2792- tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (githubv4 . NewClient ( nil ) ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
2823+ tool ,_ := PullRequestRead (stubGetClientFn (mockClient ),stubRepoAccessCache (gqlClient ,5 * time .Minute ),translations .NullTranslationHelper ,stubFeatureFlags (map [string ]bool {"lockdown-mode" :false }))
27932824require .NoError (t ,toolsnaps .Test (tool .Name ,tool ))
27942825
27952826assert .Equal (t ,"pull_request_read" ,tool .Name )