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

Function TestNewCmdDelete

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

Source from the content-addressed store, hash-verified

18)
19
20func TestNewCmdDelete(t *testing.T) {
21 tests := []struct {
22 name string
23 input string
24 tty bool
25 output DeleteOptions
26 wantErr bool
27 wantErrMsg string
28 wantStderr string
29 }{
30 {
31 name: "confirm flag",
32 tty: true,
33 input: "OWNER/REPO --confirm",
34 output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true},
35 },
36 {
37 name: "yes flag",
38 tty: true,
39 input: "OWNER/REPO --yes",
40 output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true},
41 },
42 {
43 name: "no confirmation notty",
44 input: "OWNER/REPO",
45 output: DeleteOptions{RepoArg: "OWNER/REPO"},
46 wantErr: true,
47 wantErrMsg: "--yes required when not running interactively",
48 },
49 {
50 name: "base repo resolution",
51 input: "",
52 tty: true,
53 output: DeleteOptions{},
54 },
55 {
56 name: "yes flag ignored when no argument tty",
57 tty: true,
58 input: "--yes",
59 output: DeleteOptions{Confirmed: false}, // --yes should be ignored
60 wantErr: false,
61 wantStderr: "Warning: `--yes` is ignored since no repository was specified\n",
62 },
63 {
64 name: "yes flag error when no argument notty",
65 input: "--yes",
66 wantErr: true,
67 wantErrMsg: "cannot non-interactively delete current repository. Please specify a repository or run interactively",
68 },
69 {
70 name: "confirm flag error when no argument notty",
71 input: "--confirm",
72 wantErr: true,
73 wantErrMsg: "cannot non-interactively delete current repository. Please specify a repository or run interactively",
74 },
75 {
76 name: "confirm flag also ignored when no argument tty",
77 tty: true,

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
NewCmdDeleteFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected