MCPcopy Create free account
hub / github.com/cli/cli / TestDeleteRepoMissingScope

Function TestDeleteRepoMissingScope

pkg/cmd/repo/delete/http_test.go:28–51  ·  view source on GitHub ↗

TestDeleteRepoMissingScope pins the scopes suggestion, which is the reason this call site needs the delete_repo scope declared rather than relying on what the API reports.

(t *testing.T)

Source from the content-addressed store, hash-verified

26// TestDeleteRepoMissingScope pins the scopes suggestion, which is the reason this call site
27// needs the delete_repo scope declared rather than relying on what the API reports.
28func TestDeleteRepoMissingScope(t *testing.T) {
29 reg := &httpmock.Registry{}
30 defer reg.Verify(t)
31
32 reg.Register(
33 httpmock.REST("DELETE", "repos/OWNER/REPO"),
34 func(req *http.Request) (*http.Response, error) {
35 resp, err := httpmock.StatusJSONResponse(403, map[string]string{"message": "Must have admin rights to Repository."})(req)
36 if err != nil {
37 return nil, err
38 }
39 resp.Header.Set("X-Oauth-Scopes", "repo")
40 resp.Header.Set("X-Accepted-Oauth-Scopes", "")
41 return resp, nil
42 },
43 )
44
45 err := deleteRepo(&http.Client{Transport: reg}, ghrepo.New("OWNER", "REPO"))
46 require.Error(t, err)
47
48 var httpErr api.HTTPError
49 require.ErrorAs(t, err, &httpErr)
50 assert.Contains(t, httpErr.ScopesSuggestion(), "delete_repo")
51}
52
53// TestDeleteRepoDoesNotFollowRedirect pins that a renamed or transferred repo surfaces the 3xx
54// to the caller rather than being followed. deleteRun relies on seeing that status to explain

Callers

nothing calls this directly

Calls 10

VerifyMethod · 0.95
RegisterMethod · 0.95
ScopesSuggestionMethod · 0.95
RESTFunction · 0.92
StatusJSONResponseFunction · 0.92
NewFunction · 0.92
deleteRepoFunction · 0.85
ContainsMethod · 0.80
SetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected