Test_createGist_missingScope pins the scopes suggestion, which is the reason this call site declares the gist scope rather than relying on what the API reports.
(t *testing.T)
| 421 | // Test_createGist_missingScope pins the scopes suggestion, which is the reason this call site |
| 422 | // declares the gist scope rather than relying on what the API reports. |
| 423 | func Test_createGist_missingScope(t *testing.T) { |
| 424 | reg := &httpmock.Registry{} |
| 425 | defer reg.Verify(t) |
| 426 | |
| 427 | reg.Register( |
| 428 | httpmock.REST("POST", "gists"), |
| 429 | func(req *http.Request) (*http.Response, error) { |
| 430 | resp, err := httpmock.StatusJSONResponse(404, map[string]string{"message": "Not Found"})(req) |
| 431 | if err != nil { |
| 432 | return nil, err |
| 433 | } |
| 434 | resp.Header.Set("X-Oauth-Scopes", "repo") |
| 435 | resp.Header.Set("X-Accepted-Oauth-Scopes", "") |
| 436 | return resp, nil |
| 437 | }, |
| 438 | ) |
| 439 | |
| 440 | _, err := createGist(&http.Client{Transport: reg}, "github.com", "", true, map[string]*shared.GistFile{ |
| 441 | "file.txt": {Filename: "file.txt", Content: "hello"}, |
| 442 | }) |
| 443 | require.Error(t, err) |
| 444 | |
| 445 | var httpErr api.HTTPError |
| 446 | require.ErrorAs(t, err, &httpErr) |
| 447 | assert.Contains(t, httpErr.ScopesSuggestion(), "gist") |
| 448 | } |
nothing calls this directly
no test coverage detected