summaryrefslogtreecommitdiffstats
path: root/model/oauth_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/oauth_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/oauth_test.go')
-rw-r--r--model/oauth_test.go42
1 files changed, 12 insertions, 30 deletions
diff --git a/model/oauth_test.go b/model/oauth_test.go
index 5c0547717..cbed8a633 100644
--- a/model/oauth_test.go
+++ b/model/oauth_test.go
@@ -6,6 +6,8 @@ package model
import (
"strings"
"testing"
+
+ "github.com/stretchr/testify/require"
)
func TestOAuthAppJson(t *testing.T) {
@@ -52,52 +54,32 @@ func TestOAuthAppPreUpdate(t *testing.T) {
func TestOAuthAppIsValid(t *testing.T) {
app := OAuthApp{}
- if err := app.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, app.IsValid())
app.Id = NewId()
- if err := app.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, app.IsValid())
app.CreateAt = 1
- if err := app.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, app.IsValid())
app.UpdateAt = 1
- if err := app.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, app.IsValid())
app.CreatorId = NewId()
- if err := app.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, app.IsValid())
app.ClientSecret = NewId()
- if err := app.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, app.IsValid())
app.Name = "TestOAuthApp"
- if err := app.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, app.IsValid())
app.CallbackUrls = []string{"https://nowhere.com"}
- if err := app.IsValid(); err == nil {
- t.Fatal()
- }
+ require.NotNil(t, app.IsValid())
app.Homepage = "https://nowhere.com"
- if err := app.IsValid(); err != nil {
- t.Fatal()
- }
+ require.Nil(t, app.IsValid())
app.IconURL = "https://nowhere.com/icon_image.png"
- if err := app.IsValid(); err != nil {
- t.Fatal()
- }
+ require.Nil(t, app.IsValid())
}