(t *testing.T, defaultPerm string, overrides map[string]string)
| 110 | } |
| 111 | |
| 112 | func 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 | |
| 130 | func stubFeatureFlags(enabledFlags map[string]bool) FeatureFlags { |
| 131 | return FeatureFlags{ |
no test coverage detected