* api4: fix TestGetUsersNotInTeam assertions

This test was relying on data from a previous test run. With the data cleared before each test, the assertions much match reality.

* *testlib: always InitSystemAdmin

Some tests implicitly relied on the basic user having system
administrator privileges because it was the first user created as such.
Eliminate `InitSystemAdmin` and explicitly create the system admin user
instead to avoid this ambiguity going forward.

* *testlib: drop all tables before each test

* api4: split up TestChannelDelete to avoid duplicate InitBasic

* api4: teardown in TestResetPassword, for when this test comes back

* invalidate cache on DropAllTables

This is necessary since the test store persists across tests.

* disable parallel tests

While tests within a package must be explicitly parallelized using `t.Parallel()`, tests across packages are run in parallel by default.  This causes problems given that the tests all currently share the same database instance.

Unfortunately, this also means that running the tests is much slower, but we can return to this later.
Этот коммит содержится в:
Jesse Hallam
2018-11-20 20:16:25 -05:00
коммит произвёл Joram Wilander
родитель 2555a5d45d
Коммит a78913178c
35 изменённых файлов: 271 добавлений и 327 удалений

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

@@ -15,7 +15,7 @@ import (
)
func TestGetPing(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -39,7 +39,7 @@ func TestGetPing(t *testing.T) {
}
func TestGetConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -84,7 +84,7 @@ func TestGetConfig(t *testing.T) {
}
func TestReloadConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -105,7 +105,7 @@ func TestReloadConfig(t *testing.T) {
}
func TestUpdateConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -152,7 +152,7 @@ func TestGetEnvironmentConfig(t *testing.T) {
os.Setenv("MM_SERVICESETTINGS_ENABLECUSTOMEMOJI", "true")
defer os.Unsetenv("MM_SERVICESETTINGS_SITEURL")
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
t.Run("as system admin", func(t *testing.T) {
@@ -212,7 +212,7 @@ func TestGetEnvironmentConfig(t *testing.T) {
}
func TestGetOldClientConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
testKey := "supersecretkey"
@@ -274,7 +274,7 @@ func TestGetOldClientConfig(t *testing.T) {
}
func TestGetOldClientLicense(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -307,7 +307,7 @@ func TestGetOldClientLicense(t *testing.T) {
}
func TestGetAudits(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -344,7 +344,7 @@ func TestGetAudits(t *testing.T) {
}
func TestEmailTest(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -379,7 +379,7 @@ func TestEmailTest(t *testing.T) {
}
func TestDatabaseRecycle(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -391,7 +391,7 @@ func TestDatabaseRecycle(t *testing.T) {
}
func TestInvalidateCaches(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -409,7 +409,7 @@ func TestInvalidateCaches(t *testing.T) {
}
func TestGetLogs(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -449,7 +449,7 @@ func TestGetLogs(t *testing.T) {
}
func TestPostLog(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -484,7 +484,7 @@ func TestPostLog(t *testing.T) {
}
func TestUploadLicenseFile(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -502,7 +502,7 @@ func TestUploadLicenseFile(t *testing.T) {
}
func TestRemoveLicenseFile(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -520,7 +520,7 @@ func TestRemoveLicenseFile(t *testing.T) {
}
func TestGetAnalyticsOld(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -593,7 +593,7 @@ func TestGetAnalyticsOld(t *testing.T) {
}
func TestS3TestConnection(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -672,7 +672,7 @@ func TestRedirectLocation(t *testing.T) {
mockBitlyLink := testServer.URL
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
enableLinkPreviews := *th.App.Config().ServiceSettings.EnableLinkPreviews