MCPcopy
hub / github.com/cli/cli / Test_editRun

Function Test_editRun

pkg/cmd/gist/edit/edit_test.go:140–842  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

138}
139
140func Test_editRun(t *testing.T) {
141 fileToAdd := filepath.Join(t.TempDir(), "gist-test.txt")
142 err := os.WriteFile(fileToAdd, []byte("hello"), 0600)
143 require.NoError(t, err)
144
145 tests := []struct {
146 name string
147 opts *EditOptions
148 mockGist *shared.Gist
149 mockGistList bool
150 httpStubs func(*httpmock.Registry)
151 prompterStubs func(*prompter.MockPrompter)
152 isTTY bool
153 stdin string
154 wantErr string
155 wantLastRequestParameters map[string]interface{}
156 }{
157 {
158 name: "no such gist",
159 wantErr: "gist not found: 1234",
160 opts: &EditOptions{
161 Selector: "1234",
162 },
163 },
164 {
165 name: "one file",
166 isTTY: false,
167 opts: &EditOptions{
168 Selector: "1234",
169 },
170 mockGist: &shared.Gist{
171 ID: "1234",
172 Files: map[string]*shared.GistFile{
173 "cicada.txt": {
174 Filename: "cicada.txt",
175 Content: "bwhiizzzbwhuiiizzzz",
176 Type: "text/plain",
177 },
178 },
179 Owner: &shared.GistOwner{Login: "octocat"},
180 },
181 httpStubs: func(reg *httpmock.Registry) {
182 reg.Register(httpmock.REST("POST", "gists/1234"),
183 httpmock.StatusStringResponse(201, "{}"))
184 },
185 wantLastRequestParameters: map[string]interface{}{
186 "description": "",
187 "files": map[string]interface{}{
188 "cicada.txt": map[string]interface{}{
189 "content": "new file content",
190 "filename": "cicada.txt",
191 },
192 },
193 },
194 },
195 {
196 name: "multiple files, submit, with TTY",
197 isTTY: true,

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
ExcludeMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
IndexForFunction · 0.92
NewMockPrompterFunction · 0.92
JSONResponseFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
TestFunction · 0.92
NewBlankConfigFunction · 0.92

Tested by

no test coverage detected