(t *testing.T)
| 89 | } |
| 90 | |
| 91 | func TestUploadDeployKeyHTTPError(t *testing.T) { |
| 92 | reg := &httpmock.Registry{} |
| 93 | defer reg.Verify(t) |
| 94 | |
| 95 | reg.Register( |
| 96 | httpmock.REST("POST", "repos/OWNER/REPO/keys"), |
| 97 | httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`), |
| 98 | ) |
| 99 | |
| 100 | err := uploadDeployKey( |
| 101 | &http.Client{Transport: reg}, |
| 102 | ghrepo.New("OWNER", "REPO"), |
| 103 | strings.NewReader("PUBKEY\n"), |
| 104 | "my sacred key", |
| 105 | false, |
| 106 | ) |
| 107 | |
| 108 | var httpErr api.HTTPError |
| 109 | require.ErrorAs(t, err, &httpErr) |
| 110 | assert.Equal(t, http.StatusNotFound, httpErr.StatusCode) |
| 111 | assert.Contains(t, err.Error(), "HTTP 404") |
| 112 | } |
nothing calls this directly
no test coverage detected