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

Function TestNewCmdDelete

pkg/cmd/ssh-key/delete/delete_test.go:20–109  ·  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 tty bool
24 input string
25 output DeleteOptions
26 wantErr bool
27 wantErrMsg string
28 }{
29 {
30 name: "tty",
31 tty: true,
32 input: "123",
33 output: DeleteOptions{KeyID: "123", Confirmed: false},
34 },
35 {
36 name: "confirm flag tty",
37 tty: true,
38 input: "123 --yes",
39 output: DeleteOptions{KeyID: "123", Confirmed: true},
40 },
41 {
42 name: "shorthand confirm flag tty",
43 tty: true,
44 input: "123 -y",
45 output: DeleteOptions{KeyID: "123", Confirmed: true},
46 },
47 {
48 name: "no tty",
49 input: "123",
50 wantErr: true,
51 wantErrMsg: "--yes required when not running interactively",
52 },
53 {
54 name: "confirm flag no tty",
55 input: "123 --yes",
56 output: DeleteOptions{KeyID: "123", Confirmed: true},
57 },
58 {
59 name: "shorthand confirm flag no tty",
60 input: "123 -y",
61 output: DeleteOptions{KeyID: "123", Confirmed: true},
62 },
63 {
64 name: "no args",
65 input: "",
66 wantErr: true,
67 wantErrMsg: "cannot delete: key id required",
68 },
69 {
70 name: "too many args",
71 input: "123 456",
72 wantErr: true,
73 wantErrMsg: "too many arguments",
74 },
75 }
76
77 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