aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_label_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/issue_label_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/issue_label_test.go')
-rw-r--r--models/issue_label_test.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/models/issue_label_test.go b/models/issue_label_test.go
index 33630cd901..aef3f70c03 100644
--- a/models/issue_label_test.go
+++ b/models/issue_label_test.go
@@ -98,9 +98,10 @@ func TestGetLabelsInRepoByIDs(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
labels, err := GetLabelsInRepoByIDs(1, []int64{1, 2, NonexistentID})
assert.NoError(t, err)
- assert.Len(t, labels, 2)
- assert.EqualValues(t, 1, labels[0].ID)
- assert.EqualValues(t, 2, labels[1].ID)
+ if assert.Len(t, labels, 2) {
+ assert.EqualValues(t, 1, labels[0].ID)
+ assert.EqualValues(t, 2, labels[1].ID)
+ }
}
func TestGetLabelsByRepoID(t *testing.T) {
@@ -123,8 +124,9 @@ func TestGetLabelsByIssueID(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
labels, err := GetLabelsByIssueID(1)
assert.NoError(t, err)
- assert.Len(t, labels, 1)
- assert.EqualValues(t, 1, labels[0].ID)
+ if assert.Len(t, labels, 1) {
+ assert.EqualValues(t, 1, labels[0].ID)
+ }
labels, err = GetLabelsByIssueID(NonexistentID)
assert.NoError(t, err)