summaryrefslogtreecommitdiffstats
path: root/model/authorize_test.go
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-08-09 05:26:38 -0400
committerJesús Espino <jespinog@gmail.com>2018-08-09 11:26:38 +0200
commitd8c8a19d355fdd67a984fc696269521919bb58b5 (patch)
treecb32477ac9031ae9e742434f7a2455d42e56da65 /model/authorize_test.go
parent0bbabd137bdbe04653426a1731bd8eb9225e0249 (diff)
downloadchat-d8c8a19d355fdd67a984fc696269521919bb58b5.tar.gz
chat-d8c8a19d355fdd67a984fc696269521919bb58b5.tar.bz2
chat-d8c8a19d355fdd67a984fc696269521919bb58b5.zip
avoid t.Fatal() in tests (#9189)
I've been burned a few times by tests that simply fatal, requiring me to run another build to learn more about what the mismatch was. Avoid this. This is part of a long running goal of mine to make testing "better".
Diffstat (limited to 'model/authorize_test.go')
-rw-r--r--model/authorize_test.go30
1 files changed, 9 insertions, 21 deletions
diff --git a/model/authorize_test.go b/model/authorize_test.go
index 81e059305..0775b06c1 100644
--- a/model/authorize_test.go
+++ b/model/authorize_test.go
@@ -6,6 +6,8 @@ package model
import (
"strings"
"testing"
+
+ "github.com/stretchr/testify/require"
)
func TestAuthJson(t *testing.T) {
@@ -46,9 +48,7 @@ func TestAuthIsValid(t *testing.T) {
ad := AuthData{}
- if err := ad.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, ad.IsValid())
ad.ClientId = NewRandomString(28)
if err := ad.IsValid(); err == nil {
@@ -56,9 +56,7 @@ func TestAuthIsValid(t *testing.T) {
}
ad.ClientId = NewId()
- if err := ad.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, ad.IsValid())
ad.UserId = NewRandomString(28)
if err := ad.IsValid(); err == nil {
@@ -66,9 +64,7 @@ func TestAuthIsValid(t *testing.T) {
}
ad.UserId = NewId()
- if err := ad.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, ad.IsValid())
ad.Code = NewRandomString(129)
if err := ad.IsValid(); err == nil {
@@ -81,9 +77,7 @@ func TestAuthIsValid(t *testing.T) {
}
ad.Code = NewId()
- if err := ad.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, ad.IsValid())
ad.ExpiresIn = 0
if err := ad.IsValid(); err == nil {
@@ -91,9 +85,7 @@ func TestAuthIsValid(t *testing.T) {
}
ad.ExpiresIn = 1
- if err := ad.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, ad.IsValid())
ad.CreateAt = 0
if err := ad.IsValid(); err == nil {
@@ -101,9 +93,7 @@ func TestAuthIsValid(t *testing.T) {
}
ad.CreateAt = 1
- if err := ad.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, ad.IsValid())
ad.State = NewRandomString(129)
if err := ad.IsValid(); err == nil {
@@ -121,9 +111,7 @@ func TestAuthIsValid(t *testing.T) {
}
ad.Scope = NewRandomString(128)
- if err := ad.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, ad.IsValid())
ad.RedirectUri = ""
if err := ad.IsValid(); err == nil {