Skip to content

Commit 2a559c9

Browse files
committed
Add test
1 parent e69478b commit 2a559c9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

services/gitdiff/gitdiff_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,3 +667,15 @@ func TestNoCrashes(t *testing.T) {
667667
ParsePatch(db.DefaultContext, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(testcase.gitdiff), "")
668668
}
669669
}
670+
671+
func TestParentCommitNotExits(t *testing.T) {
672+
gitRepo, err := git.OpenRepository(git.DefaultContext, "./testdata/parent-commit-not-exits")
673+
require.NoError(t, err)
674+
defer gitRepo.Close()
675+
676+
diff, err := GetDiff(git.DefaultContext, gitRepo, &DiffOptions{
677+
AfterCommitID: "d01637fe74c3727d9d1e5f691f343988d3e5342f",
678+
})
679+
assert.ErrorContains(t, err, "object does not exist [id: af35b81c4c8bd963b77b51b207ae4dc90e1904af, rel_path: ]")
680+
assert.Nil(t, diff)
681+
}

0 commit comments

Comments
 (0)