mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Ensure unittest isolation (#9819)
* 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.
This commit is contained in:
committed by
Joram Wilander
parent
2555a5d45d
commit
a78913178c
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestCreateCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
@@ -151,7 +151,7 @@ func TestUpdateCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
user := th.SystemAdminUser
|
||||
@@ -214,7 +214,7 @@ func TestDeleteCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListCommands(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -297,7 +297,7 @@ func TestListCommands(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListAutocompleteCommands(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -357,7 +357,7 @@ func TestListAutocompleteCommands(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRegenToken(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
@@ -392,7 +392,7 @@ func TestRegenToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecuteInvalidCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
@@ -455,7 +455,7 @@ func TestExecuteInvalidCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecuteGetCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
@@ -517,7 +517,7 @@ func TestExecuteGetCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecutePostCommand(t *testing.T) {
|
||||
th := Setup().InitBasic().InitSystemAdmin()
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
Reference in New Issue
Block a user