From cacdda702e2f8750f2fe0652e052f3a35c912b95 Mon Sep 17 00:00:00 2001 From: Adarsh K Kumar Date: Sun, 3 Nov 2019 20:43:23 +0530 Subject: [PATCH] MM-19663 | Migrate brand_test and cluster_test to testify (#12935) * MM-19663 | Migrate brand_test and cluster_test to testify * Use require.Fail instead of require.FailNow Co-Authored-By: Ben Schumacher --- api4/brand_test.go | 11 ++++------- api4/cluster_test.go | 5 ++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/api4/brand_test.go b/api4/brand_test.go index c454789cd6..a3cd5738b2 100644 --- a/api4/brand_test.go +++ b/api4/brand_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/mattermost/mattermost-server/utils/testutils" + "github.com/stretchr/testify/require" ) func TestGetBrandImage(t *testing.T) { @@ -32,9 +33,7 @@ func TestUploadBrandImage(t *testing.T) { Client := th.Client data, err := testutils.ReadTestFile("test.png") - if err != nil { - t.Fatal(err) - } + require.Nil(t, err) _, resp := Client.UploadBrandImage(data) CheckForbiddenStatus(t, resp) @@ -48,7 +47,7 @@ func TestUploadBrandImage(t *testing.T) { } else if resp.StatusCode == http.StatusUnauthorized { CheckUnauthorizedStatus(t, resp) } else { - t.Fatal("Should have failed either forbidden or unauthorized") + require.Fail(t, "Should have failed either forbidden or unauthorized") } _, resp = th.SystemAdminClient.UploadBrandImage(data) @@ -60,9 +59,7 @@ func TestDeleteBrandImage(t *testing.T) { defer th.TearDown() data, err := testutils.ReadTestFile("test.png") - if err != nil { - t.Fatal(err) - } + require.Nil(t, err) _, resp := th.SystemAdminClient.UploadBrandImage(data) CheckCreatedStatus(t, resp) diff --git a/api4/cluster_test.go b/api4/cluster_test.go index abc1fb515b..25287671f2 100644 --- a/api4/cluster_test.go +++ b/api4/cluster_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/mattermost/mattermost-server/model" + "github.com/stretchr/testify/require" ) func TestGetClusterStatus(t *testing.T) { @@ -22,9 +23,7 @@ func TestGetClusterStatus(t *testing.T) { infos, resp := th.SystemAdminClient.GetClusterStatus() CheckNoError(t, resp) - if infos == nil { - t.Fatal("should not be nil") - } + require.NotNil(t, infos, "cluster status should not be nil") }) t.Run("as restricted system admin", func(t *testing.T) {