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

Function Test_NewCmdStatus

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

Source from the content-addressed store, hash-verified

22)
23
24func Test_NewCmdStatus(t *testing.T) {
25 tests := []struct {
26 name string
27 cli string
28 wants StatusOptions
29 }{
30 {
31 name: "no arguments",
32 cli: "",
33 wants: StatusOptions{},
34 },
35 {
36 name: "hostname set",
37 cli: "--hostname ellie.williams",
38 wants: StatusOptions{
39 Hostname: "ellie.williams",
40 },
41 },
42 {
43 name: "show token",
44 cli: "--show-token",
45 wants: StatusOptions{
46 ShowToken: true,
47 },
48 },
49 {
50 name: "active",
51 cli: "--active",
52 wants: StatusOptions{
53 Active: true,
54 },
55 },
56 }
57
58 for _, tt := range tests {
59 t.Run(tt.name, func(t *testing.T) {
60 f := &cmdutil.Factory{}
61
62 argv, err := shlex.Split(tt.cli)
63 assert.NoError(t, err)
64
65 var gotOpts *StatusOptions
66 cmd := NewCmdStatus(f, func(opts *StatusOptions) error {
67 gotOpts = opts
68 return nil
69 })
70
71 // TODO cobra hack-around
72 cmd.Flags().BoolP("help", "x", false, "")
73
74 cmd.SetArgs(argv)
75 cmd.SetIn(&bytes.Buffer{})
76 cmd.SetOut(&bytes.Buffer{})
77 cmd.SetErr(&bytes.Buffer{})
78
79 _, err = cmd.ExecuteC()
80 assert.NoError(t, err)
81

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.80
NewCmdStatusFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected