@@ -11,6 +11,7 @@ import (
11
11
"reflect"
12
12
"strings"
13
13
"testing"
14
+ "time"
14
15
)
15
16
16
17
func TestLineOperations (t * testing.T ) {
@@ -397,6 +398,16 @@ Date: Tue Apr 2 22:55:40 2019 -0700
397
398
InputFile : "testdata/one_file.patch" ,
398
399
Output : []* File {
399
400
{
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
+ },
400
411
OldName : "dir/file1.txt" ,
401
412
NewName : "dir/file1.txt" ,
402
413
OldMode : os .FileMode (0100644 ),
@@ -411,6 +422,16 @@ Date: Tue Apr 2 22:55:40 2019 -0700
411
422
InputFile : "testdata/two_files.patch" ,
412
423
Output : []* File {
413
424
{
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
+ },
414
435
OldName : "dir/file1.txt" ,
415
436
NewName : "dir/file1.txt" ,
416
437
OldMode : os .FileMode (0100644 ),
@@ -419,6 +440,16 @@ Date: Tue Apr 2 22:55:40 2019 -0700
419
440
TextFragments : textFragments ,
420
441
},
421
442
{
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
+ },
422
453
OldName : "dir/file2.txt" ,
423
454
NewName : "dir/file2.txt" ,
424
455
OldMode : os .FileMode (0100644 ),
@@ -433,6 +464,15 @@ Date: Tue Apr 2 22:55:40 2019 -0700
433
464
InputFile : "testdata/new_binary_file.patch" ,
434
465
Output : []* File {
435
466
{
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
+ },
436
476
OldName : "" ,
437
477
NewName : "dir/ten.bin" ,
438
478
NewMode : os .FileMode (0100644 ),
@@ -556,3 +596,11 @@ func newTestParser(input string, init bool) *parser {
556
596
}
557
597
return p
558
598
}
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