@@ -10,7 +10,6 @@ import (
1010"github.com/google/go-github/v69/github"
1111"github.com/mark3labs/mcp-go/mcp"
1212"github.com/migueleliasweb/go-github-mock/src/mock"
13- "github.com/stretchr/testify/assert"
1413"github.com/stretchr/testify/require"
1514)
1615
@@ -66,7 +65,7 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
6665name string
6766mockedClient * http.Client
6867requestArgs map [string ]any
69- expectError bool
68+ expectError string
7069expectedResult any
7170expectedErrMsg string
7271}{
@@ -79,7 +78,7 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
7978),
8079),
8180requestArgs :map [string ]any {},
82- expectError :true ,
81+ expectError :"owner is required" ,
8382},
8483{
8584name :"missing repo" ,
@@ -92,7 +91,7 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
9291requestArgs :map [string ]any {
9392"owner" : []string {"owner" },
9493},
95- expectError :true ,
94+ expectError :"repo is required" ,
9695},
9796{
9897name :"successful file content fetch" ,
@@ -108,7 +107,6 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
108107"path" : []string {"README.md" },
109108"branch" : []string {"main" },
110109},
111- expectError :false ,
112110expectedResult :expectedFileContent ,
113111},
114112{
@@ -124,11 +122,25 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
124122"repo" : []string {"repo" },
125123"path" : []string {"src" },
126124},
127- expectError :false ,
128125expectedResult :expectedDirContent ,
129126},
130127{
131- name :"empty content fetch" ,
128+ name :"no data" ,
129+ mockedClient :mock .NewMockedHTTPClient (
130+ mock .WithRequestMatch (
131+ mock .GetReposContentsByOwnerByRepoByPath ,
132+ ),
133+ ),
134+ requestArgs :map [string ]any {
135+ "owner" : []string {"owner" },
136+ "repo" : []string {"repo" },
137+ "path" : []string {"src" },
138+ },
139+ expectedResult :nil ,
140+ expectError :"no repository resource content found" ,
141+ },
142+ {
143+ name :"empty data" ,
132144mockedClient :mock .NewMockedHTTPClient (
133145mock .WithRequestMatch (
134146mock .GetReposContentsByOwnerByRepoByPath ,
@@ -140,7 +152,6 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
140152"repo" : []string {"repo" },
141153"path" : []string {"src" },
142154},
143- expectError :false ,
144155expectedResult :nil ,
145156},
146157{
@@ -160,8 +171,7 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
160171"path" : []string {"nonexistent.md" },
161172"branch" : []string {"main" },
162173},
163- expectError :true ,
164- expectedErrMsg :"404 Not Found" ,
174+ expectError :"404 Not Found" ,
165175},
166176}
167177
@@ -181,9 +191,8 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
181191
182192resp ,err := handler (context .TODO (),request )
183193
184- if tc .expectError {
185- require .Error (t ,err )
186- assert .Contains (t ,err .Error (),tc .expectedErrMsg )
194+ if tc .expectError != "" {
195+ require .ErrorContains (t ,err ,tc .expectedErrMsg )
187196return
188197}
189198