Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
hiifong committed Jan 14, 2025
1 parent e69478b commit 2a559c9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions services/gitdiff/gitdiff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,15 @@ func TestNoCrashes(t *testing.T) {
ParsePatch(db.DefaultContext, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(testcase.gitdiff), "")
}
}

func TestParentCommitNotExits(t *testing.T) {
gitRepo, err := git.OpenRepository(git.DefaultContext, "./testdata/parent-commit-not-exits")
require.NoError(t, err)
defer gitRepo.Close()

diff, err := GetDiff(git.DefaultContext, gitRepo, &DiffOptions{
AfterCommitID: "d01637fe74c3727d9d1e5f691f343988d3e5342f",
})
assert.ErrorContains(t, err, "object does not exist [id: af35b81c4c8bd963b77b51b207ae4dc90e1904af, rel_path: ]")
assert.Nil(t, diff)
}

0 comments on commit 2a559c9

Please sign in to comment.