MCPcopy Index your code
hub / github.com/cli/cli / Test_deleteRun

Function Test_deleteRun

pkg/cmd/repo/delete/delete_test.go:115–240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

113}
114
115func Test_deleteRun(t *testing.T) {
116 tests := []struct {
117 name string
118 tty bool
119 opts *DeleteOptions
120 httpStubs func(*httpmock.Registry)
121 prompterStubs func(*prompter.PrompterMock)
122 wantStdout string
123 wantStderr string
124 wantErr bool
125 errMsg string
126 }{
127 {
128 name: "prompting confirmation tty",
129 tty: true,
130 opts: &DeleteOptions{RepoArg: "OWNER/REPO"},
131 wantStdout: "✓ Deleted repository OWNER/REPO\n",
132 prompterStubs: func(p *prompter.PrompterMock) {
133 p.ConfirmDeletionFunc = func(_ string) error {
134 return nil
135 }
136 },
137 httpStubs: func(reg *httpmock.Registry) {
138 reg.Register(
139 httpmock.REST("DELETE", "repos/OWNER/REPO"),
140 httpmock.StatusStringResponse(204, "{}"))
141 },
142 },
143 {
144 name: "infer base repo",
145 tty: true,
146 opts: &DeleteOptions{},
147 wantStdout: "✓ Deleted repository OWNER/REPO\n",
148 prompterStubs: func(p *prompter.PrompterMock) {
149 p.ConfirmDeletionFunc = func(_ string) error {
150 return nil
151 }
152 },
153 httpStubs: func(reg *httpmock.Registry) {
154 reg.Register(
155 httpmock.REST("DELETE", "repos/OWNER/REPO"),
156 httpmock.StatusStringResponse(204, "{}"))
157 },
158 },
159 {
160 name: "confirmation no tty",
161 opts: &DeleteOptions{
162 RepoArg: "OWNER/REPO",
163 Confirmed: true,
164 },
165 httpStubs: func(reg *httpmock.Registry) {
166 reg.Register(
167 httpmock.REST("DELETE", "repos/OWNER/REPO"),
168 httpmock.StatusStringResponse(204, "{}"))
169 },
170 },
171 {
172 name: "short repo name",

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NewFunction · 0.92
TestFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
deleteRunFunction · 0.70

Tested by

no test coverage detected