@@ -11,6 +11,7 @@ import (
1111 "github.com/github/github-mcp-server/pkg/translations"
1212 "github.com/google/go-github/v79/github"
1313 "github.com/google/jsonschema-go/jsonschema"
14+ "github.com/migueleliasweb/go-github-mock/src/mock"
1415 "github.com/stretchr/testify/assert"
1516 "github.com/stretchr/testify/require"
1617)
@@ -71,8 +72,8 @@ func Test_GetRepositoryTree(t *testing.T) {
7172 {
7273 name : "successfully get repository tree" ,
7374 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
74- "GET /repos/{owner}/{repo}" : mockResponse (t , http .StatusOK , mockRepo ),
75- "GET /repos/{owner}/{repo}/git/trees/{tree}" : mockResponse (t , http .StatusOK , mockTree ),
75+ mock . GetReposByOwnerByRepo . Method + " " + mock . GetReposByOwnerByRepo . Pattern : mockResponse (t , http .StatusOK , mockRepo ),
76+ mock . GetReposGitTreesByOwnerByRepoByTreeSha . Method + " " + mock . GetReposGitTreesByOwnerByRepoByTreeSha . Pattern : mockResponse (t , http .StatusOK , mockTree ),
7677 }),
7778 requestArgs : map [string ]interface {}{
7879 "owner" : "owner" ,
@@ -82,8 +83,8 @@ func Test_GetRepositoryTree(t *testing.T) {
8283 {
8384 name : "successfully get repository tree with path filter" ,
8485 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
85- "GET /repos/{owner}/{repo}" : mockResponse (t , http .StatusOK , mockRepo ),
86- "GET /repos/{owner}/{repo}/git/trees/{tree}" : mockResponse (t , http .StatusOK , mockTree ),
86+ mock . GetReposByOwnerByRepo . Method + " " + mock . GetReposByOwnerByRepo . Pattern : mockResponse (t , http .StatusOK , mockRepo ),
87+ mock . GetReposGitTreesByOwnerByRepoByTreeSha . Method + " " + mock . GetReposGitTreesByOwnerByRepoByTreeSha . Pattern : mockResponse (t , http .StatusOK , mockTree ),
8788 }),
8889 requestArgs : map [string ]interface {}{
8990 "owner" : "owner" ,
@@ -94,7 +95,7 @@ func Test_GetRepositoryTree(t *testing.T) {
9495 {
9596 name : "repository not found" ,
9697 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
97- "GET /repos/{owner}/{repo}" : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
98+ mock . GetReposByOwnerByRepo . Method + " " + mock . GetReposByOwnerByRepo . Pattern : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
9899 w .WriteHeader (http .StatusNotFound )
99100 _ , _ = w .Write ([]byte (`{"message": "Not Found"}` ))
100101 }),
@@ -109,8 +110,8 @@ func Test_GetRepositoryTree(t *testing.T) {
109110 {
110111 name : "tree not found" ,
111112 mockedClient : MockHTTPClientWithHandlers (map [string ]http.HandlerFunc {
112- "GET /repos/{owner}/{repo}" : mockResponse (t , http .StatusOK , mockRepo ),
113- "GET /repos/{owner}/{repo}/git/trees/{tree}" : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
113+ mock . GetReposByOwnerByRepo . Method + " " + mock . GetReposByOwnerByRepo . Pattern : mockResponse (t , http .StatusOK , mockRepo ),
114+ mock . GetReposGitTreesByOwnerByRepoByTreeSha . Method + " " + mock . GetReposGitTreesByOwnerByRepoByTreeSha . Pattern : http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
114115 w .WriteHeader (http .StatusNotFound )
115116 _ , _ = w .Write ([]byte (`{"message": "Not Found"}` ))
116117 }),
0 commit comments