aboutsummaryrefslogtreecommitdiffstats
path: root/models/star_test.go
diff options
context:
space:
mode:
authorMorlinest <Morlinest@users.noreply.github.com>2017-08-28 11:17:45 +0200
committerLauris BH <lauris@nix.lv>2017-08-28 12:17:45 +0300
commit8e61823ec403b661359373f8f8b0c9a7c9ea368d (patch)
tree0ee6d56bf3f1c01348afa2a2f03dfbd6f72815de /models/star_test.go
parentced50e0ec13085504fa19c82f018a2eecb70ff68 (diff)
downloadgitea-8e61823ec403b661359373f8f8b0c9a7c9ea368d.tar.gz
gitea-8e61823ec403b661359373f8f8b0c9a7c9ea368d.zip
Fix tests code to prevent some runtime errors (#2381)
* Fix tests code to prevent some runtime errors * Reduce nesting
Diffstat (limited to 'models/star_test.go')
-rw-r--r--models/star_test.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/models/star_test.go b/models/star_test.go
index 714f5df5cd..55b4a1cfac 100644
--- a/models/star_test.go
+++ b/models/star_test.go
@@ -35,8 +35,9 @@ func TestRepository_GetStargazers(t *testing.T) {
repo := AssertExistsAndLoadBean(t, &Repository{ID: 4}).(*Repository)
gazers, err := repo.GetStargazers(0)
assert.NoError(t, err)
- assert.Len(t, gazers, 1)
- assert.Equal(t, int64(2), gazers[0].ID)
+ if assert.Len(t, gazers, 1) {
+ assert.Equal(t, int64(2), gazers[0].ID)
+ }
}
func TestRepository_GetStargazers2(t *testing.T) {
@@ -55,14 +56,16 @@ func TestUser_GetStarredRepos(t *testing.T) {
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
starred, err := user.GetStarredRepos(false, 1, 10, "")
assert.NoError(t, err)
- assert.Len(t, starred, 1)
- assert.Equal(t, int64(4), starred[0].ID)
+ if assert.Len(t, starred, 1) {
+ assert.Equal(t, int64(4), starred[0].ID)
+ }
starred, err = user.GetStarredRepos(true, 1, 10, "")
assert.NoError(t, err)
- assert.Len(t, starred, 2)
- assert.Equal(t, int64(2), starred[0].ID)
- assert.Equal(t, int64(4), starred[1].ID)
+ if assert.Len(t, starred, 2) {
+ assert.Equal(t, int64(2), starred[0].ID)
+ assert.Equal(t, int64(4), starred[1].ID)
+ }
}
func TestUser_GetStarredRepos2(t *testing.T) {