(t *testing.T)
| 228 | } |
| 229 | |
| 230 | func TestParseNextFileHeader(t *testing.T) { |
| 231 | tests := map[string]struct { |
| 232 | Input string |
| 233 | Output *File |
| 234 | Preamble string |
| 235 | Err bool |
| 236 | }{ |
| 237 | "gitHeader": { |
| 238 | Input: `commit 1acbae563cd6ef5750a82ee64e116c6eb065cb94 |
| 239 | Author: Morton Haypenny <mhaypenny@example.com> |
| 240 | Date: Tue Apr 2 22:30:00 2019 -0700 |
| 241 | |
| 242 | This is a sample commit message. |
| 243 | |
| 244 | diff --git a/file.txt b/file.txt |
| 245 | index cc34da1..1acbae5 100644 |
| 246 | --- a/file.txt |
| 247 | +++ b/file.txt |
| 248 | @@ -1,3 +1,4 @@ |
| 249 | `, |
| 250 | Output: &File{ |
| 251 | OldName: "file.txt", |
| 252 | NewName: "file.txt", |
| 253 | OldMode: os.FileMode(0100644), |
| 254 | OldOIDPrefix: "cc34da1", |
| 255 | NewOIDPrefix: "1acbae5", |
| 256 | }, |
| 257 | Preamble: `commit 1acbae563cd6ef5750a82ee64e116c6eb065cb94 |
| 258 | Author: Morton Haypenny <mhaypenny@example.com> |
| 259 | Date: Tue Apr 2 22:30:00 2019 -0700 |
| 260 | |
| 261 | This is a sample commit message. |
| 262 | |
| 263 | `, |
| 264 | }, |
| 265 | "traditionalHeader": { |
| 266 | Input: ` |
| 267 | --- file.txt 2019-04-01 22:58:14.833597918 -0700 |
| 268 | +++ file.txt 2019-04-01 22:58:14.833597918 -0700 |
| 269 | @@ -1,3 +1,4 @@ |
| 270 | `, |
| 271 | Output: &File{ |
| 272 | OldName: "file.txt", |
| 273 | NewName: "file.txt", |
| 274 | }, |
| 275 | Preamble: "\n", |
| 276 | }, |
| 277 | "noHeaders": { |
| 278 | Input: ` |
| 279 | this is a line |
| 280 | this is another line |
| 281 | --- could this be a header? |
| 282 | nope, it's just some dashes |
| 283 | `, |
| 284 | Output: nil, |
| 285 | Preamble: ` |
| 286 | this is a line |
| 287 | this is another line |
nothing calls this directly
no test coverage detected