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 /api4/system_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 'api4/system_test.go')
-rw-r--r-- | api4/system_test.go | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/api4/system_test.go b/api4/system_test.go index 099c193d0..205572cf6 100644 --- a/api4/system_test.go +++ b/api4/system_test.go @@ -10,6 +10,7 @@ import ( "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestGetPing(t *testing.T) { @@ -47,9 +48,7 @@ func TestGetConfig(t *testing.T) { cfg, resp := th.SystemAdminClient.GetConfig() CheckNoError(t, resp) - if len(cfg.TeamSettings.SiteName) == 0 { - t.Fatal() - } + require.NotEqual(t, "", cfg.TeamSettings.SiteName) if *cfg.LdapSettings.BindPassword != model.FAKE_SETTING && len(*cfg.LdapSettings.BindPassword) != 0 { t.Fatal("did not sanitize properly") @@ -121,28 +120,14 @@ func TestUpdateConfig(t *testing.T) { cfg, resp = th.SystemAdminClient.UpdateConfig(cfg) CheckNoError(t, resp) - if len(cfg.TeamSettings.SiteName) == 0 { - t.Fatal() - } else { - if cfg.TeamSettings.SiteName != "MyFancyName" { - t.Log("It should update the SiteName") - t.Fatal() - } - } + require.Equal(t, "MyFancyName", cfg.TeamSettings.SiteName, "It should update the SiteName") //Revert the change cfg.TeamSettings.SiteName = SiteName cfg, resp = th.SystemAdminClient.UpdateConfig(cfg) CheckNoError(t, resp) - if len(cfg.TeamSettings.SiteName) == 0 { - t.Fatal() - } else { - if cfg.TeamSettings.SiteName != SiteName { - t.Log("It should update the SiteName") - t.Fatal() - } - } + require.Equal(t, SiteName, cfg.TeamSettings.SiteName, "It should update the SiteName") t.Run("Should not be able to modify PluginSettings.EnableUploads", func(t *testing.T) { oldEnableUploads := *th.App.GetConfig().PluginSettings.EnableUploads |