History

Repare and Improve GetDiffRangeWithWhitespaceBehavior (#16894)

* repare and improve GetDiffRangeWithWhitespaceBehavior * Context with Timeout

6543 committed 5 years ago

Commit bb4cc871 parent f2b4b0f5 files · +26 −37Browse files

Showing the changes to services/gitdiff/gitdiff_test.go (1 of 5 files). Show all

Unified · Split

services/gitdiff/gitdiff_test.go+7−1
@@ -13,6 +13,7 @@ import ( · 12 unmodified lines
1313 "testing"
1414
1515 "code.gitea.io/gitea/models"
16+ "code.gitea.io/gitea/modules/git"
1617 "code.gitea.io/gitea/modules/highlight"
1718 "code.gitea.io/gitea/modules/json"
1819 "code.gitea.io/gitea/modules/setting"
@@ -514,8 +515,13 @@ func TestDiffLine_GetCommentSide(t *testing.T) { · 495 unmodified lines
514515 }
515516
516517 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()
517523 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",
519525 setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffFiles, behavior)
520526 assert.NoError(t, err, fmt.Sprintf("Error when diff with %s", behavior))
521527 for _, f := range diffs.Files {