1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-05-11 05:55:29 +00:00

Fix git grep search limit, add test (#30071)

Fix #30069
This commit is contained in:
wxiaoguang
2024-03-25 21:25:22 +08:00
committed by GitHub
parent bbaf62589f
commit 8e79aed573
2 changed files with 17 additions and 1 deletions

View File

@ -31,6 +31,16 @@ func TestGrepSearch(t *testing.T) {
},
}, res)
res, err = GrepSearch(context.Background(), repo, "void", GrepOptions{MaxResultLimit: 1})
assert.NoError(t, err)
assert.Equal(t, []*GrepResult{
{
Filename: "java-hello/main.java",
LineNumbers: []int{3},
LineCodes: []string{" public static void main(String[] args)"},
},
}, res)
res, err = GrepSearch(context.Background(), repo, "no-such-content", GrepOptions{})
assert.NoError(t, err)
assert.Len(t, res, 0)