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

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

@@ -23,7 +23,7 @@ import (
)
func TestCreatePost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -120,7 +120,7 @@ func TestCreatePost(t *testing.T) {
}
func TestCreatePostEphemeral(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.SystemAdminClient
@@ -167,7 +167,7 @@ func testCreatePostWithOutgoingHook(
triggerWhen int,
commentPostType bool,
) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
user := th.SystemAdminUser
team := th.BasicTeam
@@ -356,7 +356,7 @@ func TestCreatePostWithOutgoingHook_no_content_type(t *testing.T) {
}
func TestCreatePostPublic(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -401,7 +401,7 @@ func TestCreatePostPublic(t *testing.T) {
}
func TestCreatePostAll(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -456,7 +456,7 @@ func TestCreatePostAll(t *testing.T) {
}
func TestCreatePostSendOutOfChannelMentions(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -523,7 +523,7 @@ func TestCreatePostSendOutOfChannelMentions(t *testing.T) {
}
func TestUpdatePost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
channel := th.BasicChannel
@@ -603,7 +603,7 @@ func TestUpdateOthersPostInDirectMessageChannel(t *testing.T) {
// This test checks that a sysadmin with the "EDIT_OTHERS_POSTS" permission can edit someone else's post in a
// channel without a team (DM/GM). This indirectly checks for the proper cascading all the way to system-wide roles
// on the user object of permissions based on a post in a channel with no team ID.
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
dmChannel := th.CreateDmChannel(th.SystemAdminUser)
@@ -625,7 +625,7 @@ func TestUpdateOthersPostInDirectMessageChannel(t *testing.T) {
}
func TestPatchPost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
channel := th.BasicChannel
@@ -713,7 +713,7 @@ func TestPatchPost(t *testing.T) {
}
func TestPinPost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -748,7 +748,7 @@ func TestPinPost(t *testing.T) {
}
func TestUnpinPost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -783,7 +783,7 @@ func TestUnpinPost(t *testing.T) {
}
func TestGetPostsForChannel(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -895,7 +895,7 @@ func TestGetPostsForChannel(t *testing.T) {
}
func TestGetFlaggedPostsForUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
user := th.BasicUser
@@ -1160,7 +1160,7 @@ func TestGetPostsAfterAndBefore(t *testing.T) {
}
func TestGetPost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1209,7 +1209,7 @@ func TestGetPost(t *testing.T) {
}
func TestDeletePost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1247,7 +1247,7 @@ func TestDeletePost(t *testing.T) {
}
func TestGetPostThread(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
@@ -1676,7 +1676,7 @@ func TestSearchPostsWithDateFlags(t *testing.T) {
}
func TestGetFileInfosForPost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client