diff options
author | Morlinest <Morlinest@users.noreply.github.com> | 2017-08-28 11:17:45 +0200 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-08-28 12:17:45 +0300 |
commit | 8e61823ec403b661359373f8f8b0c9a7c9ea368d (patch) | |
tree | 0ee6d56bf3f1c01348afa2a2f03dfbd6f72815de /models/user_openid_test.go | |
parent | ced50e0ec13085504fa19c82f018a2eecb70ff68 (diff) | |
download | gitea-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/user_openid_test.go')
-rw-r--r-- | models/user_openid_test.go | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/models/user_openid_test.go b/models/user_openid_test.go index e4734cc428..711f92b9ff 100644 --- a/models/user_openid_test.go +++ b/models/user_openid_test.go @@ -14,8 +14,7 @@ func TestGetUserOpenIDs(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) oids, err := GetUserOpenIDs(int64(1)) - if assert.NoError(t, err) { - assert.Len(t, oids, 2) + if assert.NoError(t, err) && assert.Len(t, oids, 2) { assert.Equal(t, oids[0].URI, "https://user1.domain1.tld/") assert.False(t, oids[0].Show) assert.Equal(t, oids[1].URI, "http://user1.domain2.tld/") @@ -23,8 +22,7 @@ func TestGetUserOpenIDs(t *testing.T) { } oids, err = GetUserOpenIDs(int64(2)) - if assert.NoError(t, err) { - assert.Len(t, oids, 1) + if assert.NoError(t, err) && assert.Len(t, oids, 1) { assert.Equal(t, oids[0].URI, "https://domain1.tld/user2/") assert.True(t, oids[0].Show) } @@ -52,10 +50,9 @@ func TestGetUserByOpenID(t *testing.T) { func TestToggleUserOpenIDVisibility(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) oids, err := GetUserOpenIDs(int64(2)) - if !assert.NoError(t, err) { + if !assert.NoError(t, err) || !assert.Len(t, oids, 1) { return } - assert.Len(t, oids, 1) assert.True(t, oids[0].Show) err = ToggleUserOpenIDVisibility(oids[0].ID) @@ -64,10 +61,10 @@ func TestToggleUserOpenIDVisibility(t *testing.T) { } oids, err = GetUserOpenIDs(int64(2)) - if assert.NoError(t, err) { - assert.Len(t, oids, 1) - assert.False(t, oids[0].Show) + if !assert.NoError(t, err) || !assert.Len(t, oids, 1) { + return } + assert.False(t, oids[0].Show) err = ToggleUserOpenIDVisibility(oids[0].ID) if !assert.NoError(t, err) { return @@ -77,6 +74,7 @@ func TestToggleUserOpenIDVisibility(t *testing.T) { if !assert.NoError(t, err) { return } - assert.Len(t, oids, 1) - assert.True(t, oids[0].Show) + if assert.Len(t, oids, 1) { + assert.True(t, oids[0].Show) + } } |