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

Function TestNewCmdDelete

pkg/cmd/ssh-key/delete/delete_test.go:18–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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