MCPcopy
hub / github.com/github/github-mcp-server / mockRESTPermissionServer

Function mockRESTPermissionServer

pkg/github/server_test.go:112–128  ·  view source on GitHub ↗
(t *testing.T, defaultPerm string, overrides map[string]string)

Source from the content-addressed store, hash-verified

110}
111
112func mockRESTPermissionServer(t *testing.T, defaultPerm string, overrides map[string]string) *gogithub.Client {
113 t.Helper()
114 return mustNewGHClient(t, MockHTTPClientWithHandler(func(w http.ResponseWriter, r *http.Request) {
115 perm := defaultPerm
116 for user, p := range overrides {
117 if strings.Contains(r.URL.Path, "/collaborators/"+user+"/") {
118 perm = p
119 break
120 }
121 }
122 resp := gogithub.RepositoryPermissionLevel{
123 Permission: gogithub.Ptr(perm),
124 }
125 w.Header().Set("Content-Type", "application/json")
126 _ = json.NewEncoder(w).Encode(resp)
127 }))
128}
129
130func stubFeatureFlags(enabledFlags map[string]bool) FeatureFlags {
131 return FeatureFlags{

Callers 4

Test_GetIssueFunction · 0.85
Test_GetIssueCommentsFunction · 0.85

Calls 3

mustNewGHClientFunction · 0.85
HeaderMethod · 0.80

Tested by

no test coverage detected