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

Function TestNewCmdDelete

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

Source from the content-addressed store, hash-verified

17)
18
19func TestNewCmdDelete(t *testing.T) {
20 tests := []struct {
21 name string
22 tty bool
23 input string
24 output DeleteOptions
25 wantErr bool
26 wantErrMsg string
27 }{
28 {
29 name: "tty",
30 tty: true,
31 input: "ABC123",
32 output: DeleteOptions{KeyID: "ABC123", Confirmed: false},
33 },
34 {
35 name: "confirm flag tty",
36 tty: true,
37 input: "ABC123 --yes",
38 output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
39 },
40 {
41 name: "shorthand confirm flag tty",
42 tty: true,
43 input: "ABC123 -y",
44 output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
45 },
46 {
47 name: "no tty",
48 input: "ABC123",
49 wantErr: true,
50 wantErrMsg: "--yes required when not running interactively",
51 },
52 {
53 name: "confirm flag no tty",
54 input: "ABC123 --yes",
55 output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
56 },
57 {
58 name: "shorthand confirm flag no tty",
59 input: "ABC123 -y",
60 output: DeleteOptions{KeyID: "ABC123", Confirmed: true},
61 },
62 {
63 name: "no args",
64 input: "",
65 wantErr: true,
66 wantErrMsg: "cannot delete: key id required",
67 },
68 {
69 name: "too many args",
70 input: "ABC123 XYZ",
71 wantErr: true,
72 wantErrMsg: "too many arguments",
73 },
74 }
75
76 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