mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-19 23:50:51 +00:00
fix: make test suite run on older git version (#8188)
Ref: forgejo/forgejo#8140, forgejo/forgejo#8144 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8188 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
53d5e6d754
commit
90f8239448
7 changed files with 71 additions and 46 deletions
|
@ -59,48 +59,55 @@ func TestGrepSearch(t *testing.T) {
|
|||
},
|
||||
}, res)
|
||||
|
||||
res, err = GrepSearch(t.Context(), repo, "world", GrepOptions{MatchesPerFile: 1})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*GrepResult{
|
||||
{
|
||||
Filename: "i-am-a-python.p",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"## This is a simple file to do a hello world"},
|
||||
HighlightedRanges: [][3]int{{0, 39, 44}},
|
||||
},
|
||||
{
|
||||
Filename: "java-hello/main.java",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"public class HelloWorld"},
|
||||
HighlightedRanges: [][3]int{{0, 18, 23}},
|
||||
},
|
||||
{
|
||||
Filename: "main.vendor.java",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"public class HelloWorld"},
|
||||
HighlightedRanges: [][3]int{{0, 18, 23}},
|
||||
},
|
||||
{
|
||||
Filename: "python-hello/hello.py",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"## This is a simple file to do a hello world"},
|
||||
HighlightedRanges: [][3]int{{0, 39, 44}},
|
||||
},
|
||||
}, res)
|
||||
t.Run("Max count", func(t *testing.T) {
|
||||
if !SupportGrepMaxCount {
|
||||
t.Skip("Skipping, git grep --max-count is not supported")
|
||||
return
|
||||
}
|
||||
|
||||
res, err = GrepSearch(t.Context(), repo, "world", GrepOptions{
|
||||
MatchesPerFile: 1,
|
||||
Filename: "java-hello/",
|
||||
res, err = GrepSearch(t.Context(), repo, "world", GrepOptions{MatchesPerFile: 1})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*GrepResult{
|
||||
{
|
||||
Filename: "i-am-a-python.p",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"## This is a simple file to do a hello world"},
|
||||
HighlightedRanges: [][3]int{{0, 39, 44}},
|
||||
},
|
||||
{
|
||||
Filename: "java-hello/main.java",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"public class HelloWorld"},
|
||||
HighlightedRanges: [][3]int{{0, 18, 23}},
|
||||
},
|
||||
{
|
||||
Filename: "main.vendor.java",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"public class HelloWorld"},
|
||||
HighlightedRanges: [][3]int{{0, 18, 23}},
|
||||
},
|
||||
{
|
||||
Filename: "python-hello/hello.py",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"## This is a simple file to do a hello world"},
|
||||
HighlightedRanges: [][3]int{{0, 39, 44}},
|
||||
},
|
||||
}, res)
|
||||
|
||||
res, err = GrepSearch(t.Context(), repo, "world", GrepOptions{
|
||||
MatchesPerFile: 1,
|
||||
Filename: "java-hello/",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*GrepResult{
|
||||
{
|
||||
Filename: "java-hello/main.java",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"public class HelloWorld"},
|
||||
HighlightedRanges: [][3]int{{0, 18, 23}},
|
||||
},
|
||||
}, res)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []*GrepResult{
|
||||
{
|
||||
Filename: "java-hello/main.java",
|
||||
LineNumbers: []int{1},
|
||||
LineCodes: []string{"public class HelloWorld"},
|
||||
HighlightedRanges: [][3]int{{0, 18, 23}},
|
||||
},
|
||||
}, res)
|
||||
|
||||
res, err = GrepSearch(t.Context(), repo, "no-such-content", GrepOptions{})
|
||||
require.NoError(t, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue