(t *testing.T)
| 167 | } |
| 168 | |
| 169 | func 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 | }, |
nothing calls this directly
no test coverage detected