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

Function TestNewCmdDelete

pkg/cmd/gpg-key/delete/delete_test.go:63–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestNewCmdDelete(t *testing.T) {
64 tests := []struct {
65 name string
66 tty bool
67 input string
68 output DeleteOptions
69 wantErr bool
70 wantErrMsg string
71 }{
72 {
73 name: "tty",
74 tty: true,
75 input: "ABC123",
76 output: DeleteOptions{KeyID: "ABC123", Confirmed: false},
77 },
78 {
79 name: "confirm flag tty",
80 tty: true,
81 input: "ABC123 --yes",
82 output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
83 },
84 {
85 name: "shorthand confirm flag tty",
86 tty: true,
87 input: "ABC123 -y",
88 output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
89 },
90 {
91 name: "no tty",
92 input: "ABC123",
93 wantErr: true,
94 wantErrMsg: "--yes required when not running interactively",
95 },
96 {
97 name: "confirm flag no tty",
98 input: "ABC123 --yes",
99 output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
100 },
101 {
102 name: "shorthand confirm flag no tty",
103 input: "ABC123 -y",
104 output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
105 },
106 {
107 name: "no args",
108 input: "",
109 wantErr: true,
110 wantErrMsg: "cannot delete: key id required",
111 },
112 {
113 name: "too many args",
114 input: "ABC123 XYZ",
115 wantErr: true,
116 wantErrMsg: "too many arguments",
117 },
118 }
119
120 for _, tt := range tests {

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
ErrorMethod · 0.45

Tested by

no test coverage detected