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

Function TestDeleteRun

pkg/cmd/issue/artifact/delete/delete_test.go:281–685  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

279}
280
281func TestDeleteRun(t *testing.T) {
282 // The spec's issue 142, plus an artifact whose type gh doesn't know and
283 // one whose name needs cleaning up. Other numbers don't exist.
284 artifacts := map[int]*client.ArtifactWithVersions{
285 2: {Number: 2, Type: "generic", Name: "OAuth callback plan"},
286 3: {Number: 3, Type: "link", Name: "Staging OAuth runbook"},
287 5: {Number: 5, Type: "generic", Name: "Barista feedback notes"},
288 7: {Number: 7, Type: "bad-type", Name: "Espresso checklist"},
289 8: {Number: 8, Type: "generic", Name: " Espresso\tmachine\n\n manual "},
290 }
291 apiError := func(status int, message string, number int) error {
292 u, err := url.Parse(fmt.Sprintf("https://api.github.com/repos/monalisa/monas-cafe/issues/142/artifacts/%d", number))
293 require.NoError(t, err)
294 return api.HTTPError{HTTPError: &ghAPI.HTTPError{StatusCode: status, Message: message, RequestURL: u}}
295 }
296
297 tests := []struct {
298 name string
299 repo ghrepo.Interface
300 opts DeleteOptions
301 tty bool
302 stderrTTY bool
303 color bool
304 isPullRequest bool
305 lookupErr error
306 deleteErrs map[int]error
307 confirm bool
308 promptErr error
309 wantPrompt string
310 wantCalls []string
311 wantStdout string
312 wantStderr string
313 wantErr string
314 wantErrIs error
315 }{
316 {
317 name: "confirming the prompt deletes the artifact",
318 opts: DeleteOptions{IssueNumber: 142, ArtifactNumbers: []int{2}},
319 tty: true,
320 confirm: true,
321 wantPrompt: "Delete artifact 2 (OAuth callback plan) from monalisa/monas-cafe#142?",
322 wantCalls: []string{
323 "IsPullRequest monalisa/monas-cafe#142",
324 "Get monalisa/monas-cafe#142 artifact 2",
325 "Delete monalisa/monas-cafe#142 artifact 2",
326 },
327 wantStdout: "! Deleted artifacts cannot be recovered.\n",
328 wantStderr: "✓ Deleted artifact 2 (OAuth callback plan) from monalisa/monas-cafe#142\n",
329 },
330 {
331 name: "one prompt lists every artifact",
332 opts: DeleteOptions{IssueNumber: 142, ArtifactNumbers: []int{2, 5}},
333 tty: true,
334 confirm: true,
335 wantPrompt: "Delete artifacts 2 (OAuth callback plan) and 5 (Barista feedback notes) from monalisa/monas-cafe#142?",
336 wantCalls: []string{
337 "IsPullRequest monalisa/monas-cafe#142",
338 "Get monalisa/monas-cafe#142 artifact 2",

Callers

nothing calls this directly

Calls 15

ConfirmCallsMethod · 0.95
NewWithHostFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
FullNameFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
SetColorEnabledMethod · 0.80
EqualMethod · 0.80
EmptyMethod · 0.80
deleteRunFunction · 0.70

Tested by

no test coverage detected