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 /cmd/mattermost | |
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 'cmd/mattermost')
-rw-r--r-- | cmd/mattermost/commands/roles_test.go | 4 | ||||
-rw-r--r-- | cmd/mattermost/commands/user_test.go | 8 |
2 files changed, 5 insertions, 7 deletions
diff --git a/cmd/mattermost/commands/roles_test.go b/cmd/mattermost/commands/roles_test.go index 4f11ce7ed..da33a73cc 100644 --- a/cmd/mattermost/commands/roles_test.go +++ b/cmd/mattermost/commands/roles_test.go @@ -17,7 +17,7 @@ func TestAssignRole(t *testing.T) { CheckCommand(t, "roles", "system_admin", th.BasicUser.Email) if result := <-th.App.Srv.Store.User().GetByEmail(th.BasicUser.Email); result.Err != nil { - t.Fatal() + t.Fatal(result.Err) } else { user := result.Data.(*model.User) if user.Roles != "system_user system_admin" { @@ -28,7 +28,7 @@ func TestAssignRole(t *testing.T) { CheckCommand(t, "roles", "member", th.BasicUser.Email) if result := <-th.App.Srv.Store.User().GetByEmail(th.BasicUser.Email); result.Err != nil { - t.Fatal() + t.Fatal(result.Err) } else { user := result.Data.(*model.User) if user.Roles != "system_user" { diff --git a/cmd/mattermost/commands/user_test.go b/cmd/mattermost/commands/user_test.go index 69ca9ecb8..088893602 100644 --- a/cmd/mattermost/commands/user_test.go +++ b/cmd/mattermost/commands/user_test.go @@ -50,12 +50,10 @@ func TestCreateUserWithoutTeam(t *testing.T) { CheckCommand(t, "user", "create", "--email", email, "--password", "mypassword1", "--username", username) if result := <-th.App.Srv.Store.User().GetByEmail(email); result.Err != nil { - t.Fatal() + t.Fatal(result.Err) } else { user := result.Data.(*model.User) - if user.Email != email { - t.Fatal() - } + require.Equal(t, email, user.Email) } } @@ -92,7 +90,7 @@ func TestChangeUserEmail(t *testing.T) { t.Fatal("should've updated to the new email") } if result := <-th.App.Srv.Store.User().GetByEmail(newEmail); result.Err != nil { - t.Fatal() + t.Fatal(result.Err) } else { user := result.Data.(*model.User) if user.Email != newEmail { |