From 04653ec924219b5296845db1d73749da4469bc09 Mon Sep 17 00:00:00 2001 From: Nikhil Ranjan Date: Tue, 17 Sep 2019 00:11:17 +0200 Subject: [PATCH] Convert app/helper_test.go t.Fatal calls into assert/require calls (#12223) * Convert app/helper_test.go t.Fatal calls into assert/require calls * using Equalf --- app/helper_test.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/app/helper_test.go b/app/helper_test.go index 947f07888c..be61728e2e 100644 --- a/app/helper_test.go +++ b/app/helper_test.go @@ -16,6 +16,7 @@ import ( "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" + "github.com/stretchr/testify/require" ) type TestHelper struct { @@ -499,22 +500,14 @@ func (me *TestHelper) ResetEmojisMigration() { func (me *TestHelper) CheckTeamCount(t *testing.T, expected int64) { teamCount, err := me.App.Srv.Store.Team().AnalyticsTeamCount() - if err != nil { - t.Fatalf("Failed to get team count.") - } - if teamCount != expected { - t.Fatalf("Unexpected number of teams. Expected: %v, found: %v", expected, teamCount) - } + require.Nil(t, err, "Failed to get team count.") + require.Equalf(t, teamCount, expected, "Unexpected number of teams. Expected: %v, found: %v", expected, teamCount) } func (me *TestHelper) CheckChannelsCount(t *testing.T, expected int64) { - if count, err := me.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_OPEN); err == nil { - if count != expected { - t.Fatalf("Unexpected number of channels. Expected: %v, found: %v", expected, count) - } - } else { - t.Fatalf("Failed to get channel count.") - } + count, err := me.App.Srv.Store.Channel().AnalyticsTypeCount("", model.CHANNEL_OPEN) + require.Nilf(t, err, "Failed to get channel count.") + require.Equalf(t, count, expected, "Unexpected number of channels. Expected: %v, found: %v", expected, count) } func (me *TestHelper) SetupTeamScheme() *model.Scheme {