* 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 удалений

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

@@ -16,7 +16,6 @@ import (
func TestCreateCommand(t *testing.T) {
th := api4.Setup().InitBasic()
th.InitSystemAdmin()
defer th.TearDown()
team := th.BasicTeam
adminUser := th.TeamAdminUser

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

@@ -15,7 +15,7 @@ func TestPlugin(t *testing.T) {
os.MkdirAll("./test-plugins", os.ModePerm)
os.MkdirAll("./test-client-plugins", os.ModePerm)
th := api4.Setup().InitBasic().InitSystemAdmin()
th := api4.Setup().InitBasic()
defer th.TearDown()
path, _ := utils.FindDir("tests")

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

@@ -12,7 +12,7 @@ import (
)
func TestCreateTeam(t *testing.T) {
th := api4.Setup().InitSystemAdmin()
th := api4.Setup().InitBasic()
defer th.TearDown()
id := model.NewId()
@@ -29,7 +29,7 @@ func TestCreateTeam(t *testing.T) {
}
func TestJoinTeam(t *testing.T) {
th := api4.Setup().InitSystemAdmin().InitBasic()
th := api4.Setup().InitBasic()
defer th.TearDown()
CheckCommand(t, "team", "add", th.BasicTeam.Name, th.BasicUser.Email)

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

@@ -12,7 +12,7 @@ import (
)
func TestCreateUserWithTeam(t *testing.T) {
th := api4.Setup().InitBasic().InitSystemAdmin()
th := api4.Setup().InitBasic()
defer th.TearDown()
id := model.NewId()

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

@@ -15,7 +15,7 @@ import (
)
func TestListWebhooks(t *testing.T) {
th := api4.Setup().InitBasic().InitSystemAdmin()
th := api4.Setup().InitBasic()
defer th.TearDown()
adminClient := th.SystemAdminClient
@@ -54,7 +54,7 @@ func TestListWebhooks(t *testing.T) {
}
func TestCreateIncomingWebhook(t *testing.T) {
th := api4.Setup().InitBasic().InitSystemAdmin()
th := api4.Setup().InitBasic()
defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
@@ -98,7 +98,7 @@ func TestCreateIncomingWebhook(t *testing.T) {
}
func TestModifyIncomingWebhook(t *testing.T) {
th := api4.Setup().InitBasic().InitSystemAdmin()
th := api4.Setup().InitBasic()
defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
@@ -153,7 +153,7 @@ func TestModifyIncomingWebhook(t *testing.T) {
}
func TestCreateOutgoingWebhook(t *testing.T) {
th := api4.Setup().InitBasic().InitSystemAdmin()
th := api4.Setup().InitBasic()
defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })