Skip to content

Commit

Permalink
Add test cases for including (and not including) repository descripti…
Browse files Browse the repository at this point in the history
…on in search.

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
  • Loading branch information
davidsvantesson committed Aug 24, 2019
1 parent 04a11c8 commit ba2d7ba
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions models/fixtures/repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
owner_id: 14
lower_name: test_repo_14
name: test_repo_14
description: test_description_14
is_private: false
num_issues: 0
num_closed_issues: 0
Expand Down
28 changes: 28 additions & 0 deletions models/repo_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,34 @@ func TestSearchRepositoryByName(t *testing.T) {
assert.Empty(t, repos)
assert.Equal(t, int64(0), count)

// Test search within description
repos, count, err = SearchRepository(&SearchRepoOptions{
Keyword: "description_14",
Page: 1,
PageSize: 10,
Collaborate: util.OptionalBoolFalse,
IncludeDescription: true,
})

assert.NoError(t, err)
if assert.Len(t, repos, 1) {
assert.Equal(t, "test_repo_14", repos[0].Name)
}
assert.Equal(t, int64(1), count)

// Test NOT search within description
repos, count, err = SearchRepository(&SearchRepoOptions{
Keyword: "description_14",
Page: 1,
PageSize: 10,
Collaborate: util.OptionalBoolFalse,
IncludeDescription: false,
})

assert.NoError(t, err)
assert.Empty(t, repos)
assert.Equal(t, int64(0), count)

testCases := []struct {
name string
opts *SearchRepoOptions
Expand Down

0 comments on commit ba2d7ba

Please sign in to comment.