MCPcopy
hub / github.com/cli/cli / Test_viewRun

Function Test_viewRun

pkg/cmd/gist/view/view_test.go:114–519  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

112}
113
114func Test_viewRun(t *testing.T) {
115 tests := []struct {
116 name string
117 opts *ViewOptions
118 wantOut string
119 mockGist *shared.Gist
120 mockGistList bool
121 isTTY bool
122 wantErr string
123 }{
124 {
125 name: "no such gist",
126 isTTY: false,
127 opts: &ViewOptions{
128 Selector: "1234",
129 ListFiles: false,
130 },
131 wantErr: "not found",
132 },
133 {
134 name: "one file",
135 isTTY: true,
136 opts: &ViewOptions{
137 Selector: "1234",
138 ListFiles: false,
139 },
140 mockGist: &shared.Gist{
141 Files: map[string]*shared.GistFile{
142 "cicada.txt": {
143 Content: "bwhiizzzbwhuiiizzzz",
144 Type: "text/plain",
145 },
146 },
147 },
148 wantOut: "bwhiizzzbwhuiiizzzz\n",
149 },
150 {
151 name: "one file, no ID supplied",
152 isTTY: true,
153 opts: &ViewOptions{
154 Selector: "",
155 ListFiles: false,
156 },
157 mockGistList: true,
158 mockGist: &shared.Gist{
159 Files: map[string]*shared.GistFile{
160 "cicada.txt": {
161 Content: "test interactive mode",
162 Type: "text/plain",
163 },
164 },
165 },
166 wantOut: "test interactive mode\n",
167 },
168 {
169 name: "no arguments notty",
170 isTTY: false,
171 wantErr: "gist ID or URL required when not running interactively",

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
JSONResponseFunction · 0.92
StringResponseFunction · 0.92
GraphQLFunction · 0.92
NewMockPrompterFunction · 0.92
NewBlankConfigFunction · 0.92
TestFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80

Tested by

no test coverage detected