Skip to content

Commit ba2d7ba

Browse files
Add test cases for including (and not including) repository description in search.
Signed-off-by: David Svantesson <[email protected]>
1 parent 04a11c8 commit ba2d7ba

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

models/fixtures/repository.yml

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
owner_id: 14
166166
lower_name: test_repo_14
167167
name: test_repo_14
168+
description: test_description_14
168169
is_private: false
169170
num_issues: 0
170171
num_closed_issues: 0

models/repo_list_test.go

+28
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,34 @@ func TestSearchRepositoryByName(t *testing.T) {
7474
assert.Empty(t, repos)
7575
assert.Equal(t, int64(0), count)
7676

77+
// Test search within description
78+
repos, count, err = SearchRepository(&SearchRepoOptions{
79+
Keyword: "description_14",
80+
Page: 1,
81+
PageSize: 10,
82+
Collaborate: util.OptionalBoolFalse,
83+
IncludeDescription: true,
84+
})
85+
86+
assert.NoError(t, err)
87+
if assert.Len(t, repos, 1) {
88+
assert.Equal(t, "test_repo_14", repos[0].Name)
89+
}
90+
assert.Equal(t, int64(1), count)
91+
92+
// Test NOT search within description
93+
repos, count, err = SearchRepository(&SearchRepoOptions{
94+
Keyword: "description_14",
95+
Page: 1,
96+
PageSize: 10,
97+
Collaborate: util.OptionalBoolFalse,
98+
IncludeDescription: false,
99+
})
100+
101+
assert.NoError(t, err)
102+
assert.Empty(t, repos)
103+
assert.Equal(t, int64(0), count)
104+
77105
testCases := []struct {
78106
name string
79107
opts *SearchRepoOptions

0 commit comments

Comments
 (0)