Skip to content

Commit ab5d7cb

Browse files
committed
Add specific tests to improve test coverage
1 parent ce0fe4e commit ab5d7cb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

models/repo_list_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,25 @@ func TestSearchRepositoryByName(t *testing.T) {
6161
assert.Equal(t, int64(3), count)
6262
assert.Len(t, repos, 3)
6363

64+
// Test non existing owner
65+
nonExistingUserID := int64(99999)
66+
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
67+
OwnerID: nonExistingUserID,
68+
})
69+
70+
if assert.Error(t, err) {
71+
assert.Equal(t, ErrUserNotExist{UID: nonExistingUserID}, err)
72+
}
73+
assert.Empty(t, repos)
74+
assert.Equal(t, int64(0), count)
75+
6476
testCases := []struct {
6577
name string
6678
opts *SearchRepoOptions
6779
count int
6880
}{
6981
{name: "PublicRepositoriesByName",
70-
opts: &SearchRepoOptions{Keyword: "big_test_", Page: 1, PageSize: 10},
82+
opts: &SearchRepoOptions{Keyword: "big_test_", PageSize: 10},
7183
count: 4},
7284
{name: "PublicAndPrivateRepositoriesByName",
7385
opts: &SearchRepoOptions{Keyword: "big_test_", Page: 1, PageSize: 10, Private: true},

0 commit comments

Comments
 (0)