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

Function Test_NewCmdView

pkg/cmd/release/view/view_test.go:46–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

44}
45
46func Test_NewCmdView(t *testing.T) {
47 tests := []struct {
48 name string
49 args string
50 isTTY bool
51 want ViewOptions
52 wantErr string
53 }{
54 {
55 name: "version argument",
56 args: "v1.2.3",
57 isTTY: true,
58 want: ViewOptions{
59 TagName: "v1.2.3",
60 WebMode: false,
61 },
62 },
63 {
64 name: "no arguments",
65 args: "",
66 isTTY: true,
67 want: ViewOptions{
68 TagName: "",
69 WebMode: false,
70 },
71 },
72 {
73 name: "web mode",
74 args: "-w",
75 isTTY: true,
76 want: ViewOptions{
77 TagName: "",
78 WebMode: true,
79 },
80 },
81 }
82 for _, tt := range tests {
83 t.Run(tt.name, func(t *testing.T) {
84 ios, _, _, _ := iostreams.Test()
85 ios.SetStdoutTTY(tt.isTTY)
86 ios.SetStdinTTY(tt.isTTY)
87 ios.SetStderrTTY(tt.isTTY)
88
89 f := &cmdutil.Factory{
90 IOStreams: ios,
91 }
92
93 var opts *ViewOptions
94 cmd := NewCmdView(f, func(o *ViewOptions) error {
95 opts = o
96 return nil
97 })
98 cmd.PersistentFlags().StringP("repo", "R", "", "")
99
100 argv, err := shlex.Split(tt.args)
101 require.NoError(t, err)
102 cmd.SetArgs(argv)
103

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
NewCmdViewFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected