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

Function Test_gpgKeyUploadDuplicateKeyBeforeWrongFormat

pkg/cmd/gpg-key/add/add_test.go:31–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func Test_gpgKeyUploadDuplicateKeyBeforeWrongFormat(t *testing.T) {
32 reg := &httpmock.Registry{}
33 defer reg.Verify(t)
34 reg.Register(
35 httpmock.REST("POST", "user/gpg_keys"),
36 httpmock.WithHeader(httpmock.StatusStringResponse(http.StatusUnprocessableEntity, `{
37 "message": "Validation Failed",
38 "errors": [{
39 "resource": "GpgKey",
40 "code": "custom",
41 "field": "key_id",
42 "message": "key_id already exists"
43 }]
44 }`), "Content-Type", "application/json"),
45 )
46
47 err := gpgKeyUpload(&http.Client{Transport: reg}, "github.com", strings.NewReader("binary-key"), "")
48
49 require.Same(t, errDuplicateKey, err)
50}
51
52func Test_gpgKeyUploadWrongFormat(t *testing.T) {
53 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 6

VerifyMethod · 0.95
RegisterMethod · 0.95
RESTFunction · 0.92
WithHeaderFunction · 0.92
StatusStringResponseFunction · 0.92
gpgKeyUploadFunction · 0.85

Tested by

no test coverage detected