diff options
author | Jesse Hallam <jesse.hallam@gmail.com> | 2018-08-09 05:26:38 -0400 |
---|---|---|
committer | Jesús Espino <jespinog@gmail.com> | 2018-08-09 11:26:38 +0200 |
commit | d8c8a19d355fdd67a984fc696269521919bb58b5 (patch) | |
tree | cb32477ac9031ae9e742434f7a2455d42e56da65 /model/access_test.go | |
parent | 0bbabd137bdbe04653426a1731bd8eb9225e0249 (diff) | |
download | chat-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/access_test.go')
-rw-r--r-- | model/access_test.go | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/model/access_test.go b/model/access_test.go index f0ed2da77..0f124a107 100644 --- a/model/access_test.go +++ b/model/access_test.go @@ -6,6 +6,8 @@ package model import ( "strings" "testing" + + "github.com/stretchr/testify/require" ) func TestAccessJson(t *testing.T) { @@ -26,9 +28,7 @@ func TestAccessJson(t *testing.T) { func TestAccessIsValid(t *testing.T) { ad := AccessData{} - if err := ad.IsValid(); err == nil { - t.Fatal() - } + require.NotNil(t, ad.IsValid()) ad.ClientId = NewRandomString(28) if err := ad.IsValid(); err == nil { @@ -41,9 +41,7 @@ func TestAccessIsValid(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 TestAccessIsValid(t *testing.T) { } ad.Token = NewId() - if err := ad.IsValid(); err == nil { - t.Fatal() - } + require.NotNil(t, ad.IsValid()) ad.RefreshToken = NewRandomString(28) if err := ad.IsValid(); err == nil { @@ -76,9 +72,7 @@ func TestAccessIsValid(t *testing.T) { } ad.RefreshToken = NewId() - if err := ad.IsValid(); err == nil { - t.Fatal() - } + require.NotNil(t, ad.IsValid()) ad.RedirectUri = "" if err := ad.IsValid(); err == nil { |