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

Function Test_NewCmdStatus

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.80
NewCmdStatusFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected