@@ -351,6 +351,40 @@ func Test_GetFileContents(t *testing.T) {
351351 Title : "File: large-file.bin" ,
352352 },
353353 },
354+ {
355+ name : "successful empty file content fetch" ,
356+ mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
357+ GetReposGitRefByOwnerByRepoByRef : mockResponse (t , http .StatusOK , "{\" ref\" : \" refs/heads/main\" , \" object\" : {\" sha\" : \" \" }}" ),
358+ GetReposByOwnerByRepo : mockResponse (t , http .StatusOK , "{\" name\" : \" repo\" , \" default_branch\" : \" main\" }" ),
359+ GetReposContentsByOwnerByRepoByPath : func (w http.ResponseWriter , _ * http.Request ) {
360+ w .WriteHeader (http .StatusOK )
361+ fileContent := & github.RepositoryContent {
362+ Name : github .Ptr (".gitkeep" ),
363+ Path : github .Ptr (".gitkeep" ),
364+ SHA : github .Ptr ("empty123" ),
365+ Type : github .Ptr ("file" ),
366+ Content : nil ,
367+ Size : github .Ptr (0 ),
368+ Encoding : github .Ptr ("base64" ),
369+ }
370+ contentBytes , _ := json .Marshal (fileContent )
371+ _ , _ = w .Write (contentBytes )
372+ },
373+ }),
374+ requestArgs : map [string ]any {
375+ "owner" : "owner" ,
376+ "repo" : "repo" ,
377+ "path" : ".gitkeep" ,
378+ "ref" : "refs/heads/main" ,
379+ },
380+ expectError : false ,
381+ expectedResult : mcp.ResourceContents {
382+ URI : "repo://owner/repo/refs/heads/main/contents/.gitkeep" ,
383+ Text : "" ,
384+ MIMEType : "text/plain" ,
385+ },
386+ expectedMsg : "successfully downloaded empty file" ,
387+ },
354388 {
355389 name : "content fetch fails" ,
356390 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
0 commit comments