(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func Test_gpgKeyUploadHTTPError(t *testing.T) { |
| 73 | reg := &httpmock.Registry{} |
| 74 | defer reg.Verify(t) |
| 75 | reg.Register( |
| 76 | httpmock.REST("POST", "user/gpg_keys"), |
| 77 | httpmock.WithHeader( |
| 78 | httpmock.StatusStringResponse(http.StatusInternalServerError, `{"message":"Internal Server Error"}`), |
| 79 | "Content-Type", "application/json", |
| 80 | ), |
| 81 | ) |
| 82 | |
| 83 | err := gpgKeyUpload(&http.Client{Transport: reg}, "github.com", strings.NewReader("-----BEGIN PGP PUBLIC KEY BLOCK-----"), "") |
| 84 | |
| 85 | var httpErr api.HTTPError |
| 86 | require.ErrorAs(t, err, &httpErr) |
| 87 | assert.Equal(t, http.StatusInternalServerError, httpErr.StatusCode) |
| 88 | assert.Contains(t, err.Error(), "HTTP 500") |
| 89 | assert.EqualError(t, err, "HTTP 500: Internal Server Error (https://api.github.com/user/gpg_keys)") |
| 90 | } |
| 91 | |
| 92 | func Test_runAdd(t *testing.T) { |
| 93 | tests := []struct { |
nothing calls this directly
no test coverage detected