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