Convert app/license_test.go t.Fatal calls into assert/require calls (#12218)

Этот коммит содержится в:
Nikhil Ranjan
2019-09-18 18:38:28 +02:00
коммит произвёл Scott Bishel
родитель 3323e7a619
Коммит 581cdf158c

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

@@ -8,6 +8,7 @@ import (
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
) )
func TestLoadLicense(t *testing.T) { func TestLoadLicense(t *testing.T) {
@@ -15,9 +16,7 @@ func TestLoadLicense(t *testing.T) {
defer th.TearDown() defer th.TearDown()
th.App.LoadLicense() th.App.LoadLicense()
if th.App.License() != nil { require.Nil(t, th.App.License(), "shouldn't have a valid license")
t.Fatal("shouldn't have a valid license")
}
} }
func TestSaveLicense(t *testing.T) { func TestSaveLicense(t *testing.T) {
@@ -26,18 +25,16 @@ func TestSaveLicense(t *testing.T) {
b1 := []byte("junk") b1 := []byte("junk")
if _, err := th.App.SaveLicense(b1); err == nil { _, err := th.App.SaveLicense(b1)
t.Fatal("shouldn't have saved license") require.NotNil(t, err, "shouldn't have saved license")
}
} }
func TestRemoveLicense(t *testing.T) { func TestRemoveLicense(t *testing.T) {
th := Setup(t) th := Setup(t)
defer th.TearDown() defer th.TearDown()
if err := th.App.RemoveLicense(); err != nil { err := th.App.RemoveLicense()
t.Fatal("should have removed license") require.Nil(t, err, "should have removed license")
}
} }
func TestSetLicense(t *testing.T) { func TestSetLicense(t *testing.T) {
@@ -49,18 +46,16 @@ func TestSetLicense(t *testing.T) {
l1.Customer = &model.Customer{} l1.Customer = &model.Customer{}
l1.StartsAt = model.GetMillis() - 1000 l1.StartsAt = model.GetMillis() - 1000
l1.ExpiresAt = model.GetMillis() + 100000 l1.ExpiresAt = model.GetMillis() + 100000
if ok := th.App.SetLicense(l1); !ok { ok := th.App.SetLicense(l1)
t.Fatal("license should have worked") require.True(t, ok, "license should have worked")
}
l3 := &model.License{} l3 := &model.License{}
l3.Features = &model.Features{} l3.Features = &model.Features{}
l3.Customer = &model.Customer{} l3.Customer = &model.Customer{}
l3.StartsAt = model.GetMillis() + 10000 l3.StartsAt = model.GetMillis() + 10000
l3.ExpiresAt = model.GetMillis() + 100000 l3.ExpiresAt = model.GetMillis() + 100000
if ok := th.App.SetLicense(l3); !ok { ok = th.App.SetLicense(l3)
t.Fatal("license should have passed") require.True(t, ok, "license should have passed")
}
} }
func TestClientLicenseEtag(t *testing.T) { func TestClientLicenseEtag(t *testing.T) {
@@ -72,16 +67,12 @@ func TestClientLicenseEtag(t *testing.T) {
th.App.SetClientLicense(map[string]string{"SomeFeature": "true", "IsLicensed": "true"}) th.App.SetClientLicense(map[string]string{"SomeFeature": "true", "IsLicensed": "true"})
etag2 := th.App.GetClientLicenseEtag(false) etag2 := th.App.GetClientLicenseEtag(false)
if etag1 == etag2 { require.NotEqual(t, etag1, etag2, "etags should not match")
t.Fatal("etags should not match")
}
th.App.SetClientLicense(map[string]string{"SomeFeature": "true", "IsLicensed": "false"}) th.App.SetClientLicense(map[string]string{"SomeFeature": "true", "IsLicensed": "false"})
etag3 := th.App.GetClientLicenseEtag(false) etag3 := th.App.GetClientLicenseEtag(false)
if etag2 == etag3 { require.NotEqual(t, etag2, etag3, "etags should not match")
t.Fatal("etags should not match")
}
} }
func TestGetSanitizedClientLicense(t *testing.T) { func TestGetSanitizedClientLicense(t *testing.T) {