* repare and improve GetDiffRangeWithWhitespaceBehavior * Context with Timeout
Showing the changes to services/gitdiff/gitdiff_test.go (1 of 5 files). Show all
Unified · Split
| @@ -13,6 +13,7 @@ import ( · 12 unmodified lines | |||
| 13 | "testing" | 13 | "testing" |
| 14 | 14 | ||
| 15 | "code.gitea.io/gitea/models" | 15 | "code.gitea.io/gitea/models" |
| 16 | "code.gitea.io/gitea/modules/git" | ||
| 16 | "code.gitea.io/gitea/modules/highlight" | 17 | "code.gitea.io/gitea/modules/highlight" |
| 17 | "code.gitea.io/gitea/modules/json" | 18 | "code.gitea.io/gitea/modules/json" |
| 18 | "code.gitea.io/gitea/modules/setting" | 19 | "code.gitea.io/gitea/modules/setting" |
| @@ -514,8 +515,13 @@ func TestDiffLine_GetCommentSide(t *testing.T) { · 495 unmodified lines | |||
| 514 | } | 515 | } |
| 515 | 516 | ||
| 516 | func TestGetDiffRangeWithWhitespaceBehavior(t *testing.T) { | 517 | func TestGetDiffRangeWithWhitespaceBehavior(t *testing.T) { |
| 518 | gitRepo, err := git.OpenRepository("./testdata/academic-module") | ||
| 519 | if !assert.NoError(t, err) { | ||
| 520 | return | ||
| 521 | } | ||
| 522 | defer gitRepo.Close() | ||
| 517 | for _, behavior := range []string{"-w", "--ignore-space-at-eol", "-b", ""} { | 523 | for _, behavior := range []string{"-w", "--ignore-space-at-eol", "-b", ""} { |
| 518 | diffs, err := GetDiffRangeWithWhitespaceBehavior("./testdata/academic-module", "559c156f8e0178b71cb44355428f24001b08fc68", "bd7063cc7c04689c4d082183d32a604ed27a24f9", | 524 | diffs, err := GetDiffRangeWithWhitespaceBehavior(gitRepo, "559c156f8e0178b71cb44355428f24001b08fc68", "bd7063cc7c04689c4d082183d32a604ed27a24f9", |
| 519 | setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffFiles, behavior) | 525 | setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffFiles, behavior) |
| 520 | assert.NoError(t, err, fmt.Sprintf("Error when diff with %s", behavior)) | 526 | assert.NoError(t, err, fmt.Sprintf("Error when diff with %s", behavior)) |
| 521 | for _, f := range diffs.Files { | 527 | for _, f := range diffs.Files { |