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

Function Test_deleteRun

pkg/cmd/repo/deploy-key/delete/delete_test.go:15–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func Test_deleteRun(t *testing.T) {
16 ios, _, stdout, stderr := iostreams.Test()
17 ios.SetStdinTTY(false)
18 ios.SetStdoutTTY(true)
19 ios.SetStderrTTY(true)
20
21 tr := httpmock.Registry{}
22 defer tr.Verify(t)
23
24 tr.Register(
25 httpmock.REST("DELETE", "repos/OWNER/REPO/keys/1234"),
26 httpmock.StringResponse(`{}`))
27
28 err := deleteRun(&DeleteOptions{
29 IO: ios,
30 HTTPClient: func() (*http.Client, error) {
31 return &http.Client{Transport: &tr}, nil
32 },
33 BaseRepo: func() (ghrepo.Interface, error) {
34 return ghrepo.New("OWNER", "REPO"), nil
35 },
36 KeyID: "1234",
37 })
38 assert.NoError(t, err)
39
40 assert.Equal(t, "", stderr.String())
41 assert.Equal(t, "✓ Deploy key deleted from OWNER/REPO\n", stdout.String())
42}
43
44func TestDeleteDeployKeyHTTPError(t *testing.T) {
45 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
RegisterMethod · 0.95
TestFunction · 0.92
RESTFunction · 0.92
StringResponseFunction · 0.92
NewFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
deleteRunFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected