Skip to content

Commit d60e122

Browse files
author
Miccah Castorina
committed
Fix gitdiff tests
1 parent 30094fc commit d60e122

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

gitdiff/parser_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"reflect"
1212
"strings"
1313
"testing"
14+
"time"
1415
)
1516

1617
func TestLineOperations(t *testing.T) {
@@ -397,6 +398,16 @@ Date: Tue Apr 2 22:55:40 2019 -0700
397398
InputFile: "testdata/one_file.patch",
398399
Output: []*File{
399400
{
401+
PatchHeader: &PatchHeader{
402+
SHA: "5d9790fec7d95aa223f3d20936340bf55ff3dcbe",
403+
Author: &PatchIdentity{
404+
Name: "Morton Haypenny",
405+
Email: "mhaypenny@example.com",
406+
},
407+
AuthorDate: asTime("2019-04-02T22:55:40-07:00"),
408+
Title: "A file with multiple fragments.",
409+
Body: "The content is arbitrary.",
410+
},
400411
OldName: "dir/file1.txt",
401412
NewName: "dir/file1.txt",
402413
OldMode: os.FileMode(0100644),
@@ -411,6 +422,16 @@ Date: Tue Apr 2 22:55:40 2019 -0700
411422
InputFile: "testdata/two_files.patch",
412423
Output: []*File{
413424
{
425+
PatchHeader: &PatchHeader{
426+
SHA: "5d9790fec7d95aa223f3d20936340bf55ff3dcbe",
427+
Author: &PatchIdentity{
428+
Name: "Morton Haypenny",
429+
Email: "mhaypenny@example.com",
430+
},
431+
AuthorDate: asTime("2019-04-02T22:55:40-07:00"),
432+
Title: "A file with multiple fragments.",
433+
Body: "The content is arbitrary.",
434+
},
414435
OldName: "dir/file1.txt",
415436
NewName: "dir/file1.txt",
416437
OldMode: os.FileMode(0100644),
@@ -419,6 +440,16 @@ Date: Tue Apr 2 22:55:40 2019 -0700
419440
TextFragments: textFragments,
420441
},
421442
{
443+
PatchHeader: &PatchHeader{
444+
SHA: "5d9790fec7d95aa223f3d20936340bf55ff3dcbe",
445+
Author: &PatchIdentity{
446+
Name: "Morton Haypenny",
447+
Email: "mhaypenny@example.com",
448+
},
449+
AuthorDate: asTime("2019-04-02T22:55:40-07:00"),
450+
Title: "A file with multiple fragments.",
451+
Body: "The content is arbitrary.",
452+
},
422453
OldName: "dir/file2.txt",
423454
NewName: "dir/file2.txt",
424455
OldMode: os.FileMode(0100644),
@@ -433,6 +464,15 @@ Date: Tue Apr 2 22:55:40 2019 -0700
433464
InputFile: "testdata/new_binary_file.patch",
434465
Output: []*File{
435466
{
467+
PatchHeader: &PatchHeader{
468+
SHA: "5d9790fec7d95aa223f3d20936340bf55ff3dcbe",
469+
Author: &PatchIdentity{
470+
Name: "Morton Haypenny",
471+
Email: "mhaypenny@example.com",
472+
},
473+
AuthorDate: asTime("2019-04-02T22:55:40-07:00"),
474+
Title: "A binary file with the first 10 fibonacci numbers.",
475+
},
436476
OldName: "",
437477
NewName: "dir/ten.bin",
438478
NewMode: os.FileMode(0100644),
@@ -556,3 +596,11 @@ func newTestParser(input string, init bool) *parser {
556596
}
557597
return p
558598
}
599+
600+
func asTime(s string) time.Time {
601+
t, err := time.Parse(time.RFC3339, s)
602+
if err != nil {
603+
panic(err)
604+
}
605+
return t
606+
}

0 commit comments

Comments
 (0)