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

Function Test_deleteRun

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

Source from the content-addressed store, hash-verified

154}
155
156func Test_deleteRun(t *testing.T) {
157 tests := []struct {
158 name string
159 tty bool
160 opts *DeleteOptions
161 httpStubs func(*httpmock.Registry)
162 prompterStubs func(*prompter.PrompterMock)
163 wantConfirmPrompt string
164 wantConfirmDeletion string
165 wantStdout string
166 wantStderr string
167 wantErr bool
168 errMsg string
169 wantScopesSuggestion string
170 }{
171 {
172 name: "prompting confirmation tty",
173 tty: true,
174 opts: &DeleteOptions{RepoArg: "OWNER/REPO"},
175 wantConfirmDeletion: "OWNER/REPO",
176 wantStdout: "✓ Deleted repository OWNER/REPO\n",
177 prompterStubs: func(p *prompter.PrompterMock) {
178 p.ConfirmDeletionFunc = func(_ string) error {
179 return nil
180 }
181 },
182 httpStubs: func(reg *httpmock.Registry) {
183 reg.Register(
184 httpmock.REST("GET", "repos/OWNER/REPO"),
185 httpmock.StringResponse(`{"private":false,"fork":false,"forks_count":0}`))
186 reg.Register(
187 httpmock.REST("DELETE", "repos/OWNER/REPO"),
188 httpmock.StatusStringResponse(204, "{}"))
189 },
190 },
191 {
192 name: "infer base repo",
193 tty: true,
194 opts: &DeleteOptions{},
195 wantConfirmDeletion: "OWNER/REPO",
196 wantStdout: "✓ Deleted repository OWNER/REPO\n",
197 prompterStubs: func(p *prompter.PrompterMock) {
198 p.ConfirmDeletionFunc = func(_ string) error {
199 return nil
200 }
201 },
202 httpStubs: func(reg *httpmock.Registry) {
203 reg.Register(
204 httpmock.REST("GET", "repos/OWNER/REPO"),
205 httpmock.StringResponse(`{"private":false,"fork":false,"forks_count":0}`))
206 reg.Register(
207 httpmock.REST("DELETE", "repos/OWNER/REPO"),
208 httpmock.StatusStringResponse(204, "{}"))
209 },
210 },
211 {
212 name: "confirmation no tty",
213 opts: &DeleteOptions{

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
ScopesSuggestionMethod · 0.95
ConfirmCallsMethod · 0.95
ConfirmDeletionCallsMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
StatusStringResponseFunction · 0.92
GraphQLFunction · 0.92
WithHeaderFunction · 0.92
WithHostFunction · 0.92
StatusJSONResponseFunction · 0.92

Tested by

no test coverage detected