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

Function Test_viewRun

pkg/cmd/gist/view/view_test.go:114–619  ·  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: "truncated raw file with escape sequences is sanitized on a terminal",
152 isTTY: true,
153 opts: &ViewOptions{
154 Selector: "1234",
155 ListFiles: false,
156 },
157 mockGist: &shared.Gist{
158 Files: map[string]*shared.GistFile{
159 "escaped.txt": {
160 Type: "text/plain",
161 Content: "",
162 Truncated: true,
163 RawURL: "https://gist.githubusercontent.com/user/1234/raw/escaped.txt",
164 },
165 },
166 },
167 wantOut: "danger^[[31m\n",
168 },
169 {
170 name: "piped truncated raw file with escape sequences is refused",
171 isTTY: false,

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
NewMockConfigFunction · 0.92
TestFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80

Tested by

no test coverage detected