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

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

@@ -86,7 +86,7 @@ func TestCreateTeam(t *testing.T) {
}
func TestCreateTeamSanitization(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
// Non-admin users can create a team, but they become a team admin by doing so
@@ -125,7 +125,7 @@ func TestCreateTeamSanitization(t *testing.T) {
}
func TestGetTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -172,7 +172,7 @@ func TestGetTeam(t *testing.T) {
}
func TestGetTeamSanitization(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
@@ -215,7 +215,7 @@ func TestGetTeamSanitization(t *testing.T) {
}
func TestGetTeamUnread(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -249,7 +249,7 @@ func TestGetTeamUnread(t *testing.T) {
}
func TestUpdateTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -344,7 +344,7 @@ func TestUpdateTeam(t *testing.T) {
}
func TestUpdateTeamSanitization(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
@@ -376,7 +376,7 @@ func TestUpdateTeamSanitization(t *testing.T) {
}
func TestPatchTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -439,7 +439,7 @@ func TestPatchTeam(t *testing.T) {
}
func TestPatchTeamSanitization(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
@@ -471,7 +471,7 @@ func TestPatchTeamSanitization(t *testing.T) {
}
func TestSoftDeleteTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -513,7 +513,7 @@ func TestSoftDeleteTeam(t *testing.T) {
}
func TestPermanentDeleteTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -554,7 +554,7 @@ func TestPermanentDeleteTeam(t *testing.T) {
}
func TestGetAllTeams(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -627,7 +627,7 @@ func TestGetAllTeams(t *testing.T) {
}
func TestGetAllTeamsSanitization(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
@@ -692,7 +692,7 @@ func TestGetAllTeamsSanitization(t *testing.T) {
}
func TestGetTeamByName(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -739,7 +739,7 @@ func TestGetTeamByName(t *testing.T) {
}
func TestGetTeamByNameSanitization(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
@@ -782,7 +782,7 @@ func TestGetTeamByNameSanitization(t *testing.T) {
}
func TestSearchAllTeams(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
oTeam := th.BasicTeam
@@ -864,7 +864,7 @@ func TestSearchAllTeams(t *testing.T) {
}
func TestSearchAllTeamsSanitization(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
@@ -940,7 +940,7 @@ func TestSearchAllTeamsSanitization(t *testing.T) {
}
func TestGetTeamsForUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -982,7 +982,7 @@ func TestGetTeamsForUser(t *testing.T) {
}
func TestGetTeamsForUserSanitization(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
@@ -1052,7 +1052,7 @@ func TestGetTeamsForUserSanitization(t *testing.T) {
}
func TestGetTeamMember(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -1089,7 +1089,7 @@ func TestGetTeamMember(t *testing.T) {
}
func TestGetTeamMembers(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -1154,7 +1154,7 @@ func TestGetTeamMembers(t *testing.T) {
}
func TestGetTeamMembersForUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1230,7 +1230,7 @@ func TestGetTeamMembersByIds(t *testing.T) {
}
func TestAddTeamMember(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -1411,7 +1411,7 @@ func TestAddTeamMember(t *testing.T) {
}
func TestAddTeamMembers(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -1512,7 +1512,7 @@ func TestAddTeamMembers(t *testing.T) {
}
func TestRemoveTeamMember(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1543,7 +1543,7 @@ func TestRemoveTeamMember(t *testing.T) {
}
func TestGetTeamStats(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -1598,7 +1598,7 @@ func TestGetTeamStats(t *testing.T) {
}
func TestUpdateTeamMemberRoles(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
SystemAdminClient := th.SystemAdminClient
@@ -1676,7 +1676,7 @@ func TestUpdateTeamMemberRoles(t *testing.T) {
}
func TestUpdateTeamMemberSchemeRoles(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
SystemAdminClient := th.SystemAdminClient
th.LoginBasic()
@@ -1751,7 +1751,7 @@ func TestUpdateTeamMemberSchemeRoles(t *testing.T) {
}
func TestGetMyTeamsUnread(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1782,7 +1782,7 @@ func TestGetMyTeamsUnread(t *testing.T) {
}
func TestTeamExists(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -1807,7 +1807,7 @@ func TestTeamExists(t *testing.T) {
}
func TestImportTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
t.Run("ImportTeam", func(t *testing.T) {
@@ -1886,7 +1886,7 @@ func TestImportTeam(t *testing.T) {
}
func TestInviteUsersToTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
user1 := th.GenerateTestEmail()
@@ -1996,7 +1996,7 @@ func TestInviteUsersToTeam(t *testing.T) {
}
func TestGetTeamInviteInfo(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -2024,7 +2024,7 @@ func TestGetTeamInviteInfo(t *testing.T) {
}
func TestSetTeamIcon(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -2087,7 +2087,7 @@ func TestSetTeamIcon(t *testing.T) {
}
func TestGetTeamIcon(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -2103,7 +2103,7 @@ func TestGetTeamIcon(t *testing.T) {
}
func TestRemoveTeamIcon(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
team := th.BasicTeam
@@ -2140,7 +2140,7 @@ func TestRemoveTeamIcon(t *testing.T) {
}
func TestUpdateTeamScheme(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
th.App.SetLicense(model.NewTestLicense(""))