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

Function TestNewCmdStatus

pkg/cmd/status/status_test.go:27–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25}
26
27func TestNewCmdStatus(t *testing.T) {
28 tests := []struct {
29 name string
30 cli string
31 wants StatusOptions
32 }{
33 {
34 name: "defaults",
35 },
36 {
37 name: "org",
38 cli: "-o cli",
39 wants: StatusOptions{
40 Org: "cli",
41 },
42 },
43 {
44 name: "exclude",
45 cli: "-e cli/cli,cli/go-gh",
46 wants: StatusOptions{
47 Exclude: []string{"cli/cli", "cli/go-gh"},
48 },
49 },
50 }
51
52 for _, tt := range tests {
53 ios, _, _, _ := iostreams.Test()
54 ios.SetStdinTTY(true)
55 ios.SetStdoutTTY(true)
56
57 if tt.wants.Exclude == nil {
58 tt.wants.Exclude = []string{}
59 }
60
61 f := &cmdutil.Factory{
62 IOStreams: ios,
63 Config: func() (gh.Config, error) {
64 return config.NewBlankConfig(), nil
65 },
66 }
67 t.Run(tt.name, func(t *testing.T) {
68 argv, err := shlex.Split(tt.cli)
69 assert.NoError(t, err)
70
71 var gotOpts *StatusOptions
72 cmd := NewCmdStatus(f, func(opts *StatusOptions) error {
73 gotOpts = opts
74 return nil
75 })
76 cmd.SetArgs(argv)
77 cmd.SetIn(&bytes.Buffer{})
78 _, err = cmd.ExecuteC()
79 assert.NoError(t, err)
80
81 assert.Equal(t, tt.wants.Org, gotOpts.Org)
82 assert.Equal(t, tt.wants.Exclude, gotOpts.Exclude)
83 })
84 }

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
NewBlankConfigFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
NewCmdStatusFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected