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

Function Test_NewCmdView

pkg/cmd/pr/view/view_test.go:80–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func Test_NewCmdView(t *testing.T) {
81 tests := []struct {
82 name string
83 args string
84 isTTY bool
85 want ViewOptions
86 wantErr string
87 }{
88 {
89 name: "number argument",
90 args: "123",
91 isTTY: true,
92 want: ViewOptions{
93 SelectorArg: "123",
94 BrowserMode: false,
95 },
96 },
97 {
98 name: "no argument",
99 args: "",
100 isTTY: true,
101 want: ViewOptions{
102 SelectorArg: "",
103 BrowserMode: false,
104 },
105 },
106 {
107 name: "web mode",
108 args: "123 -w",
109 isTTY: true,
110 want: ViewOptions{
111 SelectorArg: "123",
112 BrowserMode: true,
113 },
114 },
115 {
116 name: "no argument with --repo override",
117 args: "-R owner/repo",
118 isTTY: true,
119 wantErr: "argument required when using the --repo flag",
120 },
121 {
122 name: "comments",
123 args: "123 -c",
124 isTTY: true,
125 want: ViewOptions{
126 SelectorArg: "123",
127 Comments: true,
128 },
129 },
130 }
131 for _, tt := range tests {
132 t.Run(tt.name, func(t *testing.T) {
133 ios, _, _, _ := iostreams.Test()
134 ios.SetStdoutTTY(tt.isTTY)
135 ios.SetStdinTTY(tt.isTTY)
136 ios.SetStderrTTY(tt.isTTY)
137

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