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 <ben.schumacher@mattermost.com>
Этот коммит содержится в:
Adarsh K Kumar
2019-11-03 20:43:23 +05:30
коммит произвёл Eli Yukelzon
родитель a2adf7b3f5
Коммит cacdda702e
2 изменённых файлов: 6 добавлений и 10 удалений

Просмотреть файл

@@ -8,6 +8,7 @@ import (
"testing" "testing"
"github.com/mattermost/mattermost-server/utils/testutils" "github.com/mattermost/mattermost-server/utils/testutils"
"github.com/stretchr/testify/require"
) )
func TestGetBrandImage(t *testing.T) { func TestGetBrandImage(t *testing.T) {
@@ -32,9 +33,7 @@ func TestUploadBrandImage(t *testing.T) {
Client := th.Client Client := th.Client
data, err := testutils.ReadTestFile("test.png") data, err := testutils.ReadTestFile("test.png")
if err != nil { require.Nil(t, err)
t.Fatal(err)
}
_, resp := Client.UploadBrandImage(data) _, resp := Client.UploadBrandImage(data)
CheckForbiddenStatus(t, resp) CheckForbiddenStatus(t, resp)
@@ -48,7 +47,7 @@ func TestUploadBrandImage(t *testing.T) {
} else if resp.StatusCode == http.StatusUnauthorized { } else if resp.StatusCode == http.StatusUnauthorized {
CheckUnauthorizedStatus(t, resp) CheckUnauthorizedStatus(t, resp)
} else { } 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) _, resp = th.SystemAdminClient.UploadBrandImage(data)
@@ -60,9 +59,7 @@ func TestDeleteBrandImage(t *testing.T) {
defer th.TearDown() defer th.TearDown()
data, err := testutils.ReadTestFile("test.png") data, err := testutils.ReadTestFile("test.png")
if err != nil { require.Nil(t, err)
t.Fatal(err)
}
_, resp := th.SystemAdminClient.UploadBrandImage(data) _, resp := th.SystemAdminClient.UploadBrandImage(data)
CheckCreatedStatus(t, resp) CheckCreatedStatus(t, resp)

Просмотреть файл

@@ -7,6 +7,7 @@ import (
"testing" "testing"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
"github.com/stretchr/testify/require"
) )
func TestGetClusterStatus(t *testing.T) { func TestGetClusterStatus(t *testing.T) {
@@ -22,9 +23,7 @@ func TestGetClusterStatus(t *testing.T) {
infos, resp := th.SystemAdminClient.GetClusterStatus() infos, resp := th.SystemAdminClient.GetClusterStatus()
CheckNoError(t, resp) CheckNoError(t, resp)
if infos == nil { require.NotNil(t, infos, "cluster status should not be nil")
t.Fatal("should not be nil")
}
}) })
t.Run("as restricted system admin", func(t *testing.T) { t.Run("as restricted system admin", func(t *testing.T) {