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

Function Test_createRun

pkg/cmd/gist/create/create_test.go:169–393  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func Test_createRun(t *testing.T) {
170 tempDir := t.TempDir()
171 fixtureFile := filepath.Join(tempDir, "fixture.txt")
172 assert.NoError(t, os.WriteFile(fixtureFile, []byte("{}"), 0644))
173 emptyFile := filepath.Join(tempDir, "empty.txt")
174 assert.NoError(t, os.WriteFile(emptyFile, []byte(" \t\n"), 0644))
175
176 tests := []struct {
177 name string
178 opts *CreateOptions
179 stdin string
180 wantOut string
181 wantStderr string
182 wantParams map[string]any
183 wantErr bool
184 wantBrowse string
185 responseStatus int
186 }{
187 {
188 name: "public",
189 opts: &CreateOptions{
190 Public: true,
191 Filenames: []string{fixtureFile},
192 },
193 wantOut: "https://gist.github.com/aa5a315d61ae9438b18d\n",
194 wantStderr: "- Creating gist fixture.txt\n✓ Created public gist fixture.txt\n",
195 wantErr: false,
196 wantParams: map[string]any{
197 "description": "",
198 "updated_at": "0001-01-01T00:00:00Z",
199 "public": true,
200 "files": map[string]any{
201 "fixture.txt": map[string]any{
202 "content": "{}",
203 },
204 },
205 },
206 responseStatus: http.StatusOK,
207 },
208 {
209 name: "with description",
210 opts: &CreateOptions{
211 Description: "an incredibly interesting gist",
212 Filenames: []string{fixtureFile},
213 },
214 wantOut: "https://gist.github.com/aa5a315d61ae9438b18d\n",
215 wantStderr: "- Creating gist fixture.txt\n✓ Created secret gist fixture.txt\n",
216 wantErr: false,
217 wantParams: map[string]any{
218 "description": "an incredibly interesting gist",
219 "updated_at": "0001-01-01T00:00:00Z",
220 "public": false,
221 "files": map[string]any{
222 "fixture.txt": map[string]any{
223 "content": "{}",
224 },
225 },
226 },

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
StatusStringResponseFunction · 0.92
NewMockConfigFunction · 0.92
TestFunction · 0.92
StubFunction · 0.92
JoinMethod · 0.80
EqualMethod · 0.80
createRunFunction · 0.70

Tested by

no test coverage detected