MCPcopy
hub / github.com/cli/cli / TestNewCmdSet

Function TestNewCmdSet

pkg/cmd/alias/set/set_test.go:18–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestNewCmdSet(t *testing.T) {
19 tests := []struct {
20 name string
21 input string
22 output SetOptions
23 wantErr bool
24 errMsg string
25 }{
26 {
27 name: "no arguments",
28 input: "",
29 wantErr: true,
30 errMsg: "accepts 2 arg(s), received 0",
31 },
32 {
33 name: "only one argument",
34 input: "name",
35 wantErr: true,
36 errMsg: "accepts 2 arg(s), received 1",
37 },
38 {
39 name: "name and expansion",
40 input: "alias-name alias-expansion",
41 output: SetOptions{
42 Name: "alias-name",
43 Expansion: "alias-expansion",
44 },
45 },
46 {
47 name: "shell flag",
48 input: "alias-name alias-expansion --shell",
49 output: SetOptions{
50 Name: "alias-name",
51 Expansion: "alias-expansion",
52 IsShell: true,
53 },
54 },
55 {
56 name: "clobber flag",
57 input: "alias-name alias-expansion --clobber",
58 output: SetOptions{
59 Name: "alias-name",
60 Expansion: "alias-expansion",
61 OverwriteExisting: true,
62 },
63 },
64 }
65 for _, tt := range tests {
66 t.Run(tt.name, func(t *testing.T) {
67 ios, _, _, _ := iostreams.Test()
68 f := &cmdutil.Factory{
69 IOStreams: ios,
70 }
71 argv, err := shlex.Split(tt.input)
72 assert.NoError(t, err)
73 var gotOpts *SetOptions
74 cmd := NewCmdSet(f, func(opts *SetOptions) error {
75 gotOpts = opts

Callers

nothing calls this directly

Calls 4

TestFunction · 0.92
EqualMethod · 0.80
NewCmdSetFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected