aboutsummaryrefslogtreecommitdiffstats
path: root/models/token_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/token_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/token_test.go')
-rw-r--r--models/token_test.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/models/token_test.go b/models/token_test.go
index 9674be126a..540bd40deb 100644
--- a/models/token_test.go
+++ b/models/token_test.go
@@ -48,17 +48,19 @@ func TestListAccessTokens(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
tokens, err := ListAccessTokens(1)
assert.NoError(t, err)
- assert.Len(t, tokens, 2)
- assert.Equal(t, int64(1), tokens[0].UID)
- assert.Equal(t, int64(1), tokens[1].UID)
- assert.Contains(t, []string{tokens[0].Name, tokens[1].Name}, "Token A")
- assert.Contains(t, []string{tokens[0].Name, tokens[1].Name}, "Token B")
+ if assert.Len(t, tokens, 2) {
+ assert.Equal(t, int64(1), tokens[0].UID)
+ assert.Equal(t, int64(1), tokens[1].UID)
+ assert.Contains(t, []string{tokens[0].Name, tokens[1].Name}, "Token A")
+ assert.Contains(t, []string{tokens[0].Name, tokens[1].Name}, "Token B")
+ }
tokens, err = ListAccessTokens(2)
assert.NoError(t, err)
- assert.Len(t, tokens, 1)
- assert.Equal(t, int64(2), tokens[0].UID)
- assert.Equal(t, "Token A", tokens[0].Name)
+ if assert.Len(t, tokens, 1) {
+ assert.Equal(t, int64(2), tokens[0].UID)
+ assert.Equal(t, "Token A", tokens[0].Name)
+ }
tokens, err = ListAccessTokens(100)
assert.NoError(t, err)