|
5 | 5 | package gitdiff
|
6 | 6 |
|
7 | 7 | import (
|
| 8 | + "context" |
8 | 9 | "strconv"
|
9 | 10 | "strings"
|
10 | 11 | "testing"
|
@@ -628,23 +629,25 @@ func TestDiffLine_GetCommentSide(t *testing.T) {
|
628 | 629 | }
|
629 | 630 |
|
630 | 631 | func TestGetDiffRangeWithWhitespaceBehavior(t *testing.T) {
|
631 |
| - gitRepo, err := git.OpenRepository(git.DefaultContext, "./testdata/academic-module") |
| 632 | + gitRepo, err := git.OpenRepository(context.Background(), "../../modules/git/tests/repos/repo5_pulls") |
632 | 633 | require.NoError(t, err)
|
633 | 634 |
|
634 | 635 | defer gitRepo.Close()
|
635 | 636 | for _, behavior := range []git.TrustedCmdArgs{{"-w"}, {"--ignore-space-at-eol"}, {"-b"}, nil} {
|
636 |
| - diffs, err := GetDiff(db.DefaultContext, gitRepo, |
| 637 | + diffs, err := GetDiff(context.Background(), gitRepo, |
637 | 638 | &DiffOptions{
|
638 |
| - AfterCommitID: "bd7063cc7c04689c4d082183d32a604ed27a24f9", |
639 |
| - BeforeCommitID: "559c156f8e0178b71cb44355428f24001b08fc68", |
| 639 | + AfterCommitID: "d8e0bbb45f200e67d9a784ce55bd90821af45ebd", |
| 640 | + BeforeCommitID: "72866af952e98d02a73003501836074b286a78f6", |
640 | 641 | MaxLines: setting.Git.MaxGitDiffLines,
|
641 | 642 | MaxLineCharacters: setting.Git.MaxGitDiffLineCharacters,
|
642 |
| - MaxFiles: setting.Git.MaxGitDiffFiles, |
| 643 | + MaxFiles: 1, |
643 | 644 | WhitespaceBehavior: behavior,
|
644 | 645 | })
|
645 |
| - assert.NoError(t, err, "Error when diff with %s", behavior) |
| 646 | + require.NoError(t, err, "Error when diff with WhitespaceBehavior=%s", behavior) |
| 647 | + assert.True(t, diffs.IsIncomplete) |
| 648 | + assert.Len(t, diffs.Files, 1) |
646 | 649 | for _, f := range diffs.Files {
|
647 |
| - assert.NotEmpty(t, f.Sections, "%s should have sections", f.Name) |
| 650 | + assert.NotEmpty(t, f.Sections, "Diff file %q should have sections", f.Name) |
648 | 651 | }
|
649 | 652 | }
|
650 | 653 | }
|
|
0 commit comments