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

Function Test_NewCmdView

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

Source from the content-addressed store, hash-verified

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

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