Skip to content

Commit d16f88e

Browse files
committed
Update tests
1 parent 6550a05 commit d16f88e

File tree

2 files changed

+129
-60
lines changed

2 files changed

+129
-60
lines changed

diff_test.go

Lines changed: 88 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ func TestDiff(t *testing.T) {
144144
isBinary: false,
145145
isSubmodule: false,
146146
isIncomplete: false,
147+
mode: 100644,
148+
oldMode: 100644,
147149
},
148150
},
149151
totalAdditions: 10,
@@ -185,9 +187,10 @@ index 0000000..6b08f76
185187
expDiff: &Diff{
186188
Files: []*DiffFile{
187189
{
188-
Name: ".gitmodules",
189-
Type: DiffFileAdd,
190-
Index: "6abde17",
190+
Name: ".gitmodules",
191+
Type: DiffFileAdd,
192+
Index: "6abde17",
193+
OldIndex: "0000000",
191194
Sections: []*DiffSection{
192195
{
193196
Lines: []*DiffLine{
@@ -217,15 +220,18 @@ index 0000000..6b08f76
217220
},
218221
numAdditions: 3,
219222
numDeletions: 0,
220-
oldName: "",
223+
oldName: ".gitmodules",
221224
isBinary: false,
222225
isSubmodule: false,
223226
isIncomplete: false,
227+
mode: 0100644,
228+
oldMode: 0100644,
224229
},
225230
{
226-
Name: "gogs/docs-api",
227-
Type: DiffFileAdd,
228-
Index: "6b08f76",
231+
Name: "gogs/docs-api",
232+
Type: DiffFileAdd,
233+
Index: "6b08f76",
234+
OldIndex: "0000000",
229235
Sections: []*DiffSection{
230236
{
231237
Lines: []*DiffLine{
@@ -245,10 +251,12 @@ index 0000000..6b08f76
245251
},
246252
numAdditions: 1,
247253
numDeletions: 0,
248-
oldName: "",
254+
oldName: "gogs/docs-api",
249255
isBinary: false,
250256
isSubmodule: true,
251257
isIncomplete: false,
258+
mode: 0160000,
259+
oldMode: 0160000,
252260
},
253261
},
254262
totalAdditions: 4,
@@ -273,9 +281,10 @@ index ee791be..9997571 100644
273281
expDiff: &Diff{
274282
Files: []*DiffFile{
275283
{
276-
Name: "pom.xml",
277-
Type: DiffFileChange,
278-
Index: "9997571",
284+
Name: "pom.xml",
285+
Type: DiffFileChange,
286+
Index: "9997571",
287+
OldIndex: "ee791be",
279288
Sections: []*DiffSection{
280289
{
281290
Lines: []*DiffLine{
@@ -330,10 +339,12 @@ index ee791be..9997571 100644
330339
},
331340
numAdditions: 1,
332341
numDeletions: 1,
333-
oldName: "",
342+
oldName: "pom.xml",
334343
isBinary: false,
335344
isSubmodule: false,
336345
isIncomplete: false,
346+
oldMode: 0100644,
347+
mode: 0100644,
337348
},
338349
},
339350
totalAdditions: 1,
@@ -352,13 +363,16 @@ Binary files /dev/null and b/img/sourcegraph.png differ`,
352363
Name: "img/sourcegraph.png",
353364
Type: DiffFileAdd,
354365
Index: "2ce9188",
366+
OldIndex: "0000000",
355367
Sections: nil,
356368
numAdditions: 0,
357369
numDeletions: 0,
358-
oldName: "",
370+
oldName: "img/sourcegraph.png",
359371
isBinary: true,
360372
isSubmodule: false,
361373
isIncomplete: false,
374+
mode: 0100644,
375+
oldMode: 0100644,
362376
},
363377
},
364378
totalAdditions: 0,
@@ -375,14 +389,17 @@ index e69de29..0000000`,
375389
{
376390
Name: "fix.txt",
377391
Type: DiffFileDelete,
378-
Index: "e69de29",
392+
Index: "0000000",
393+
OldIndex: "e69de29",
379394
Sections: nil,
380395
numAdditions: 0,
381396
numDeletions: 0,
382-
oldName: "",
397+
oldName: "fix.txt",
383398
isBinary: false,
384399
isSubmodule: false,
385400
isIncomplete: false,
401+
mode: 0100644,
402+
oldMode: 0100644,
386403
},
387404
},
388405
totalAdditions: 0,
@@ -431,9 +448,10 @@ index b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0..ab80bda5dd90d8b42be25ac2c7a071b7
431448
expDiff: &Diff{
432449
Files: []*DiffFile{
433450
{
434-
Name: "dir/file.txt",
435-
Type: DiffFileChange,
436-
Index: "ab80bda5dd90d8b42be25ac2c7a071b722171f09",
451+
Name: "dir/file.txt",
452+
Type: DiffFileChange,
453+
Index: "ab80bda5dd90d8b42be25ac2c7a071b722171f09",
454+
OldIndex: "b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0",
437455
Sections: []*DiffSection{
438456
{
439457
Lines: []*DiffLine{
@@ -468,10 +486,12 @@ index b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0..ab80bda5dd90d8b42be25ac2c7a071b7
468486
},
469487
numAdditions: 3,
470488
numDeletions: 1,
471-
oldName: "",
489+
oldName: "dir/file.txt",
472490
isBinary: false,
473491
isSubmodule: false,
474492
isIncomplete: false,
493+
mode: 0100644,
494+
oldMode: 0100644,
475495
},
476496
},
477497
totalAdditions: 3,
@@ -499,9 +519,10 @@ index ce53c7e..56a156b 100644
499519
expDiff: &Diff{
500520
Files: []*DiffFile{
501521
{
502-
Name: "src/app/tabs/friends/friends.module.ts",
503-
Type: DiffFileRename,
504-
Index: "56a156b",
522+
Name: "src/app/tabs/friends/friends.module.ts",
523+
Type: DiffFileRename,
524+
Index: "56a156b",
525+
OldIndex: "ce53c7e",
505526
Sections: []*DiffSection{
506527
{
507528
Lines: []*DiffLine{
@@ -557,6 +578,8 @@ index ce53c7e..56a156b 100644
557578
numAdditions: 2,
558579
numDeletions: 2,
559580
oldName: "src/app/tabs/teacher/teacher.module.ts",
581+
mode: 0100644,
582+
oldMode: 0100644,
560583
},
561584
},
562585
totalAdditions: 2,
@@ -590,9 +613,10 @@ index 335db7ea..51d7543e 100644
590613
expDiff: &Diff{
591614
Files: []*DiffFile{
592615
{
593-
Name: ".travis.yml",
594-
Type: DiffFileChange,
595-
Index: "51d7543e",
616+
Name: ".travis.yml",
617+
Type: DiffFileChange,
618+
Index: "51d7543e",
619+
OldIndex: "335db7ea",
596620
Sections: []*DiffSection{
597621
{
598622
Lines: []*DiffLine{
@@ -652,10 +676,12 @@ index 335db7ea..51d7543e 100644
652676
},
653677
numAdditions: 0,
654678
numDeletions: 3,
655-
oldName: "",
679+
oldName: ".travis.yml",
656680
isBinary: false,
657681
isSubmodule: false,
658682
isIncomplete: true,
683+
mode: 0100644,
684+
oldMode: 0100644,
659685
},
660686
},
661687
totalAdditions: 0,
@@ -677,9 +703,10 @@ index 0000000..6abde17
677703
expDiff: &Diff{
678704
Files: []*DiffFile{
679705
{
680-
Name: ".gitmodules",
681-
Type: DiffFileAdd,
682-
Index: "6abde17",
706+
Name: ".gitmodules",
707+
Type: DiffFileAdd,
708+
Index: "6abde17",
709+
OldIndex: "0000000",
683710
Sections: []*DiffSection{
684711
{
685712
Lines: []*DiffLine{
@@ -704,10 +731,12 @@ index 0000000..6abde17
704731
},
705732
numAdditions: 2,
706733
numDeletions: 0,
707-
oldName: "",
734+
oldName: ".gitmodules",
708735
isBinary: false,
709736
isSubmodule: false,
710737
isIncomplete: true,
738+
mode: 0100644,
739+
oldMode: 0100644,
711740
},
712741
},
713742
totalAdditions: 2,
@@ -738,9 +767,10 @@ index 0000000..6b08f76
738767
expDiff: &Diff{
739768
Files: []*DiffFile{
740769
{
741-
Name: ".gitmodules",
742-
Type: DiffFileAdd,
743-
Index: "6abde17",
770+
Name: ".gitmodules",
771+
Type: DiffFileAdd,
772+
Index: "6abde17",
773+
OldIndex: "0000000",
744774
Sections: []*DiffSection{
745775
{
746776
Lines: []*DiffLine{
@@ -765,17 +795,41 @@ index 0000000..6b08f76
765795
},
766796
numAdditions: 2,
767797
numDeletions: 0,
768-
oldName: "",
798+
oldName: ".gitmodules",
769799
isBinary: false,
770800
isSubmodule: false,
771801
isIncomplete: true,
802+
mode: 0100644,
803+
oldMode: 0100644,
772804
},
773805
},
774806
totalAdditions: 2,
775807
totalDeletions: 0,
776808
isIncomplete: true,
777809
},
778810
},
811+
{
812+
input: `diff --git a/go.mod b/go.mod
813+
old mode 100644
814+
new mode 100755`,
815+
maxFileLines: 0,
816+
maxLineChars: 0,
817+
maxFiles: 1,
818+
expDiff: &Diff{
819+
Files: []*DiffFile{
820+
{
821+
Name: "go.mod",
822+
oldName: "go.mod",
823+
Type: DiffFileChange,
824+
mode: 0100755,
825+
oldMode: 0100644,
826+
},
827+
},
828+
totalAdditions: 0,
829+
totalDeletions: 0,
830+
isIncomplete: false,
831+
},
832+
},
779833
}
780834
for _, test := range tests {
781835
t.Run("", func(t *testing.T) {

0 commit comments

Comments
 (0)