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)
| 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. |
| 28 | func 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 |
nothing calls this directly
no test coverage detected