Browse Source

Fix "index out of range" runtime error in repo_list tests (#2376)

for-closed-social
Morlinest 7 years ago
committed by Lunny Xiao
parent
commit
0f2c98adcd
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      models/repo_list_test.go

+ 6
- 2
models/repo_list_test.go View File

@ -23,7 +23,9 @@ func TestSearchRepositoryByName(t *testing.T) {
assert.NotNil(t, repos) assert.NotNil(t, repos)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "test_repo_12", repos[0].Name)
if assert.Len(t, repos, 1) {
assert.Equal(t, "test_repo_12", repos[0].Name)
}
assert.Equal(t, int64(1), count) assert.Equal(t, int64(1), count)
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{ repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
@ -48,7 +50,9 @@ func TestSearchRepositoryByName(t *testing.T) {
assert.NotNil(t, repos) assert.NotNil(t, repos)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "test_repo_13", repos[0].Name)
if assert.Len(t, repos, 1) {
assert.Equal(t, "test_repo_13", repos[0].Name)
}
assert.Equal(t, int64(1), count) assert.Equal(t, int64(1), count)
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{ repos, count, err = SearchRepositoryByName(&SearchRepoOptions{

Loading…
Cancel
Save