77 "testing"
88
99 "github.com/github/github-mcp-server/pkg/raw"
10- "github.com/github/github-mcp-server/pkg/translations"
1110 "github.com/google/go-github/v79/github"
1211 "github.com/migueleliasweb/go-github-mock/src/mock"
1312 "github.com/modelcontextprotocol/go-sdk/mcp"
@@ -28,7 +27,7 @@ func Test_repositoryResourceContents(t *testing.T) {
2827 name string
2928 mockedClient * http.Client
3029 uri string
31- handlerFn func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler
30+ handlerFn func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler
3231 expectedResponseType resourceResponseType
3332 expectError string
3433 expectedResult * mcp.ReadResourceResult
@@ -46,8 +45,8 @@ func Test_repositoryResourceContents(t *testing.T) {
4645 ),
4746 ),
4847 uri : "repo:///repo/contents/README.md" ,
49- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
50- return GetRepositoryResourceContent (getClient , getRawClient , t ). Handler
48+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
49+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourceContentURITemplate )
5150 },
5251 expectedResponseType : resourceResponseTypeText , // Ignored as error is expected
5352 expectError : "owner is required" ,
@@ -65,8 +64,8 @@ func Test_repositoryResourceContents(t *testing.T) {
6564 ),
6665 ),
6766 uri : "repo://owner//refs/heads/main/contents/README.md" ,
68- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
69- return GetRepositoryResourceBranchContent (getClient , getRawClient , t ). Handler
67+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
68+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourceBranchContentURITemplate )
7069 },
7170 expectedResponseType : resourceResponseTypeText , // Ignored as error is expected
7271 expectError : "repo is required" ,
@@ -84,8 +83,8 @@ func Test_repositoryResourceContents(t *testing.T) {
8483 ),
8584 ),
8685 uri : "repo://owner/repo/contents/data.png" ,
87- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
88- return GetRepositoryResourceContent (getClient , getRawClient , t ). Handler
86+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
87+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourceContentURITemplate )
8988 },
9089 expectedResponseType : resourceResponseTypeBlob ,
9190 expectedResult : & mcp.ReadResourceResult {
@@ -108,8 +107,8 @@ func Test_repositoryResourceContents(t *testing.T) {
108107 ),
109108 ),
110109 uri : "repo://owner/repo/contents/README.md" ,
111- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
112- return GetRepositoryResourceContent (getClient , getRawClient , t ). Handler
110+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
111+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourceContentURITemplate )
113112 },
114113 expectedResponseType : resourceResponseTypeText ,
115114 expectedResult : & mcp.ReadResourceResult {
@@ -134,8 +133,8 @@ func Test_repositoryResourceContents(t *testing.T) {
134133 ),
135134 ),
136135 uri : "repo://owner/repo/contents/pkg/github/actions.go" ,
137- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
138- return GetRepositoryResourceContent (getClient , getRawClient , t ). Handler
136+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
137+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourceContentURITemplate )
139138 },
140139 expectedResponseType : resourceResponseTypeText ,
141140 expectedResult : & mcp.ReadResourceResult {
@@ -158,8 +157,8 @@ func Test_repositoryResourceContents(t *testing.T) {
158157 ),
159158 ),
160159 uri : "repo://owner/repo/refs/heads/main/contents/README.md" ,
161- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
162- return GetRepositoryResourceBranchContent (getClient , getRawClient , t ). Handler
160+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
161+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourceBranchContentURITemplate )
163162 },
164163 expectedResponseType : resourceResponseTypeText ,
165164 expectedResult : & mcp.ReadResourceResult {
@@ -182,8 +181,8 @@ func Test_repositoryResourceContents(t *testing.T) {
182181 ),
183182 ),
184183 uri : "repo://owner/repo/refs/tags/v1.0.0/contents/README.md" ,
185- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
186- return GetRepositoryResourceTagContent (getClient , getRawClient , t ). Handler
184+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
185+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourceTagContentURITemplate )
187186 },
188187 expectedResponseType : resourceResponseTypeText ,
189188 expectedResult : & mcp.ReadResourceResult {
@@ -206,8 +205,8 @@ func Test_repositoryResourceContents(t *testing.T) {
206205 ),
207206 ),
208207 uri : "repo://owner/repo/sha/abc123/contents/README.md" ,
209- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
210- return GetRepositoryResourceCommitContent (getClient , getRawClient , t ). Handler
208+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
209+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourceCommitContentURITemplate )
211210 },
212211 expectedResponseType : resourceResponseTypeText ,
213212 expectedResult : & mcp.ReadResourceResult {
@@ -238,8 +237,8 @@ func Test_repositoryResourceContents(t *testing.T) {
238237 ),
239238 ),
240239 uri : "repo://owner/repo/refs/pull/42/head/contents/README.md" ,
241- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
242- return GetRepositoryResourcePrContent (getClient , getRawClient , t ). Handler
240+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
241+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourcePrContentURITemplate )
243242 },
244243 expectedResponseType : resourceResponseTypeText ,
245244 expectedResult : & mcp.ReadResourceResult {
@@ -261,8 +260,8 @@ func Test_repositoryResourceContents(t *testing.T) {
261260 ),
262261 ),
263262 uri : "repo://owner/repo/contents/nonexistent.md" ,
264- handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn , t translations. TranslationHelperFunc ) mcp.ResourceHandler {
265- return GetRepositoryResourceContent (getClient , getRawClient , t ). Handler
263+ handlerFn : func (getClient GetClientFn , getRawClient raw.GetRawClientFn ) mcp.ResourceHandler {
264+ return RepositoryResourceContentsHandler (getClient , getRawClient , repositoryResourceContentURITemplate )
266265 },
267266 expectedResponseType : resourceResponseTypeText , // Ignored as error is expected
268267 expectError : "404 Not Found" ,
@@ -273,7 +272,7 @@ func Test_repositoryResourceContents(t *testing.T) {
273272 t .Run (tc .name , func (t * testing.T ) {
274273 client := github .NewClient (tc .mockedClient )
275274 mockRawClient := raw .NewClient (client , base )
276- handler := tc .handlerFn (stubGetClientFn (client ), stubGetRawClientFn (mockRawClient ), translations . NullTranslationHelper )
275+ handler := tc .handlerFn (stubGetClientFn (client ), stubGetRawClientFn (mockRawClient ))
277276
278277 request := & mcp.ReadResourceRequest {
279278 Params : & mcp.ReadResourceParams {
0 commit comments