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/utils_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/utils_test.go')
-rw-r--r-- | model/utils_test.go | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/model/utils_test.go b/model/utils_test.go index 9797c7090..d35146b30 100644 --- a/model/utils_test.go +++ b/model/utils_test.go @@ -34,18 +34,14 @@ func TestAppError(t *testing.T) { err := NewAppError("TestAppError", "message", nil, "", http.StatusInternalServerError) json := err.ToJson() rerr := AppErrorFromJson(strings.NewReader(json)) - if err.Message != rerr.Message { - t.Fatal() - } + require.Equal(t, err.Message, rerr.Message) t.Log(err.Error()) } func TestAppErrorJunk(t *testing.T) { rerr := AppErrorFromJson(strings.NewReader("<html><body>This is a broken test</body></html>")) - if "body: <html><body>This is a broken test</body></html>" != rerr.DetailedError { - t.Fatal() - } + require.Equal(t, "body: <html><body>This is a broken test</body></html>", rerr.DetailedError) } func TestCopyStringMap(t *testing.T) { @@ -173,9 +169,7 @@ func TestValidLower(t *testing.T) { func TestEtag(t *testing.T) { etag := Etag("hello", 24) - if len(etag) <= 0 { - t.Fatal() - } + require.NotEqual(t, "", etag) } var hashtags = map[string]string{ |