@@ -34,12 +34,11 @@ func Test_repositoryResourceContents(t *testing.T) {
3434 {
3535 name : "missing owner" ,
3636 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
37- GetRawReposContentsByOwnerByRepoByPath :
38- http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
39- w .Header ().Set ("Content-Type" , "text/markdown" )
40- _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
41- require .NoError (t , err )
42- }),
37+ GetRawReposContentsByOwnerByRepoByPath : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
38+ w .Header ().Set ("Content-Type" , "text/markdown" )
39+ _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
40+ require .NoError (t , err )
41+ }),
4342 }),
4443 uri : "repo:///repo/contents/README.md" ,
4544 handlerFn : func (deps ToolDependencies ) mcp.ResourceHandler {
@@ -51,12 +50,11 @@ func Test_repositoryResourceContents(t *testing.T) {
5150 {
5251 name : "missing repo" ,
5352 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
54- GetRawReposContentsByOwnerByRepoByBranchByPath :
55- http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
56- w .Header ().Set ("Content-Type" , "text/markdown" )
57- _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
58- require .NoError (t , err )
59- }),
53+ GetRawReposContentsByOwnerByRepoByBranchByPath : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
54+ w .Header ().Set ("Content-Type" , "text/markdown" )
55+ _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
56+ require .NoError (t , err )
57+ }),
6058 }),
6159 uri : "repo://owner//refs/heads/main/contents/README.md" ,
6260 handlerFn : func (deps ToolDependencies ) mcp.ResourceHandler {
@@ -68,12 +66,11 @@ func Test_repositoryResourceContents(t *testing.T) {
6866 {
6967 name : "successful blob content fetch" ,
7068 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
71- GetRawReposContentsByOwnerByRepoByPath :
72- http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
73- w .Header ().Set ("Content-Type" , "image/png" )
74- _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
75- require .NoError (t , err )
76- }),
69+ GetRawReposContentsByOwnerByRepoByPath : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
70+ w .Header ().Set ("Content-Type" , "image/png" )
71+ _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
72+ require .NoError (t , err )
73+ }),
7774 }),
7875 uri : "repo://owner/repo/contents/data.png" ,
7976 handlerFn : func (deps ToolDependencies ) mcp.ResourceHandler {
@@ -90,12 +87,11 @@ func Test_repositoryResourceContents(t *testing.T) {
9087 {
9188 name : "successful text content fetch (HEAD)" ,
9289 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
93- GetRawReposContentsByOwnerByRepoByPath :
94- http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
95- w .Header ().Set ("Content-Type" , "text/markdown" )
96- _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
97- require .NoError (t , err )
98- }),
90+ GetRawReposContentsByOwnerByRepoByPath : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
91+ w .Header ().Set ("Content-Type" , "text/markdown" )
92+ _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
93+ require .NoError (t , err )
94+ }),
9995 }),
10096 uri : "repo://owner/repo/contents/README.md" ,
10197 handlerFn : func (deps ToolDependencies ) mcp.ResourceHandler {
@@ -112,14 +108,13 @@ func Test_repositoryResourceContents(t *testing.T) {
112108 {
113109 name : "successful text content fetch (HEAD)" ,
114110 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
115- GetRawReposContentsByOwnerByRepoByPath :
116- http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
117- w .Header ().Set ("Content-Type" , "text/plain" )
111+ GetRawReposContentsByOwnerByRepoByPath : http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
112+ w .Header ().Set ("Content-Type" , "text/plain" )
118113
119- require .Contains (t , r .URL .Path , "pkg/github/actions.go" )
120- _ , err := w .Write ([]byte ("package actions\n \n func main() {\n // Sample Go file content\n }\n " ))
121- require .NoError (t , err )
122- }),
114+ require .Contains (t , r .URL .Path , "pkg/github/actions.go" )
115+ _ , err := w .Write ([]byte ("package actions\n \n func main() {\n // Sample Go file content\n }\n " ))
116+ require .NoError (t , err )
117+ }),
123118 }),
124119 uri : "repo://owner/repo/contents/pkg/github/actions.go" ,
125120 handlerFn : func (deps ToolDependencies ) mcp.ResourceHandler {
@@ -136,12 +131,11 @@ func Test_repositoryResourceContents(t *testing.T) {
136131 {
137132 name : "successful text content fetch (branch)" ,
138133 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
139- GetRawReposContentsByOwnerByRepoByBranchByPath :
140- http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
141- w .Header ().Set ("Content-Type" , "text/markdown" )
142- _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
143- require .NoError (t , err )
144- }),
134+ GetRawReposContentsByOwnerByRepoByBranchByPath : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
135+ w .Header ().Set ("Content-Type" , "text/markdown" )
136+ _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
137+ require .NoError (t , err )
138+ }),
145139 }),
146140 uri : "repo://owner/repo/refs/heads/main/contents/README.md" ,
147141 handlerFn : func (deps ToolDependencies ) mcp.ResourceHandler {
@@ -158,12 +152,11 @@ func Test_repositoryResourceContents(t *testing.T) {
158152 {
159153 name : "successful text content fetch (tag)" ,
160154 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
161- GetRawReposContentsByOwnerByRepoByTagByPath :
162- http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
163- w .Header ().Set ("Content-Type" , "text/markdown" )
164- _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
165- require .NoError (t , err )
166- }),
155+ GetRawReposContentsByOwnerByRepoByTagByPath : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
156+ w .Header ().Set ("Content-Type" , "text/markdown" )
157+ _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
158+ require .NoError (t , err )
159+ }),
167160 }),
168161 uri : "repo://owner/repo/refs/tags/v1.0.0/contents/README.md" ,
169162 handlerFn : func (deps ToolDependencies ) mcp.ResourceHandler {
@@ -180,12 +173,11 @@ func Test_repositoryResourceContents(t *testing.T) {
180173 {
181174 name : "successful text content fetch (sha)" ,
182175 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
183- GetRawReposContentsByOwnerByRepoBySHAByPath :
184- http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
185- w .Header ().Set ("Content-Type" , "text/markdown" )
186- _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
187- require .NoError (t , err )
188- }),
176+ GetRawReposContentsByOwnerByRepoBySHAByPath : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
177+ w .Header ().Set ("Content-Type" , "text/markdown" )
178+ _ , err := w .Write ([]byte ("# Test Repository\n \n This is a test repository." ))
179+ require .NoError (t , err )
180+ }),
189181 }),
190182 uri : "repo://owner/repo/sha/abc123/contents/README.md" ,
191183 handlerFn : func (deps ToolDependencies ) mcp.ResourceHandler {
@@ -269,11 +261,11 @@ func Test_repositoryResourceContents(t *testing.T) {
269261
270262 content := resp .Contents [0 ]
271263 switch tc .expectedResponseType {
272- case resourceResponseTypeBlob :
264+ case resourceResponseTypeBlob :
273265 require .Equal (t , tc .expectedResult .Contents [0 ].Blob , content .Blob )
274- case resourceResponseTypeText :
266+ case resourceResponseTypeText :
275267 require .Equal (t , tc .expectedResult .Contents [0 ].Text , content .Text )
276- default :
268+ default :
277269 t .Fatalf ("unknown expectedResponseType %v" , tc .expectedResponseType )
278270 }
279271 })
0 commit comments