* add request context

* move initialialization to server

* use app interface instead of global app functions

* remove app context from webconn

* cleanup

* remove duplicated services

* move context to separate package

* remove finalize init method and move content to NewServer function

* restart workers and schedulers after adding license for tests

* reflect review comments

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2021-05-11 13:00:44 +03:00
коммит произвёл GitHub
родитель c09369f14a
Коммит 5ea06e51d0
235 изменённых файлов: 4048 добавлений и 3819 удалений

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

@@ -448,7 +448,7 @@ func TestCreateDirectChannelAsGuest(t *testing.T) {
Password: "Password1",
EmailVerified: true,
}
guest, err := th.App.CreateGuest(guest)
guest, err := th.App.CreateGuest(th.Context, guest)
require.Nil(t, err)
_, resp := Client.Login(guest.Username, "Password1")
@@ -575,7 +575,7 @@ func TestCreateGroupChannelAsGuest(t *testing.T) {
Password: "Password1",
EmailVerified: true,
}
guest, err := th.App.CreateGuest(guest)
guest, err := th.App.CreateGuest(th.Context, guest)
require.Nil(t, err)
_, resp := Client.Login(guest.Username, "Password1")
@@ -943,12 +943,12 @@ func TestGetChannelsForTeamForUser(t *testing.T) {
TeamId: th.BasicTeam.Id,
CreatorId: th.BasicUser.Id,
}
th.App.CreateChannel(testChannel, true)
th.App.CreateChannel(th.Context, testChannel, true)
defer th.App.PermanentDeleteChannel(testChannel)
channels, resp := Client.GetChannelsForTeamForUser(th.BasicTeam.Id, th.BasicUser.Id, false, "")
CheckNoError(t, resp)
assert.Equal(t, 6, len(channels))
th.App.DeleteChannel(testChannel, th.BasicUser.Id)
th.App.DeleteChannel(th.Context, testChannel, th.BasicUser.Id)
channels, resp = Client.GetChannelsForTeamForUser(th.BasicTeam.Id, th.BasicUser.Id, false, "")
CheckNoError(t, resp)
assert.Equal(t, 5, len(channels))
@@ -1182,7 +1182,7 @@ func TestSearchChannels(t *testing.T) {
})
t.Run("Remove the user from BasicChannel and search again, should not be returned", func(t *testing.T) {
th.App.RemoveUserFromChannel(th.BasicUser.Id, th.BasicUser.Id, th.BasicChannel)
th.App.RemoveUserFromChannel(th.Context, th.BasicUser.Id, th.BasicUser.Id, th.BasicChannel)
search.Term = th.BasicChannel.Name
channelList, resp := Client.SearchChannels(th.BasicTeam.Id, search)
@@ -1270,7 +1270,7 @@ func TestSearchArchivedChannels(t *testing.T) {
})
t.Run("Remove the user from BasicDeletedChannel and search again, should still return", func(t *testing.T) {
th.App.RemoveUserFromChannel(th.BasicUser.Id, th.BasicUser.Id, th.BasicDeletedChannel)
th.App.RemoveUserFromChannel(th.Context, th.BasicUser.Id, th.BasicUser.Id, th.BasicDeletedChannel)
search.Term = th.BasicDeletedChannel.Name
channelList, resp := Client.SearchArchivedChannels(th.BasicTeam.Id, search)
@@ -2878,7 +2878,7 @@ func TestRemoveChannelMember(t *testing.T) {
*cfg.ServiceSettings.EnableBotAccountCreation = true
})
bot := th.CreateBotWithSystemAdminClient()
th.App.AddUserToTeam(team.Id, bot.UserId, "")
th.App.AddUserToTeam(th.Context, team.Id, bot.UserId, "")
pass, resp := Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser2.Id)
CheckNoError(t, resp)
@@ -3166,13 +3166,13 @@ func TestAutocompleteChannelsForSearch(t *testing.T) {
th.LoginBasicWithClient(th.Client)
u1 := th.CreateUserWithClient(th.SystemAdminClient)
defer th.App.PermanentDeleteUser(u1)
defer th.App.PermanentDeleteUser(th.Context, u1)
u2 := th.CreateUserWithClient(th.SystemAdminClient)
defer th.App.PermanentDeleteUser(u2)
defer th.App.PermanentDeleteUser(th.Context, u2)
u3 := th.CreateUserWithClient(th.SystemAdminClient)
defer th.App.PermanentDeleteUser(u3)
defer th.App.PermanentDeleteUser(th.Context, u3)
u4 := th.CreateUserWithClient(th.SystemAdminClient)
defer th.App.PermanentDeleteUser(u4)
defer th.App.PermanentDeleteUser(th.Context, u4)
// A private channel to make sure private channels are not used
utils.DisableDebugLogForTest()
@@ -3278,7 +3278,7 @@ func TestAutocompleteChannelsForSearchGuestUsers(t *testing.T) {
defer th.TearDown()
u1 := th.CreateUserWithClient(th.SystemAdminClient)
defer th.App.PermanentDeleteUser(u1)
defer th.App.PermanentDeleteUser(th.Context, u1)
enableGuestAccounts := *th.App.Config().GuestAccountsSettings.Enable
defer func() {
@@ -3296,7 +3296,7 @@ func TestAutocompleteChannelsForSearchGuestUsers(t *testing.T) {
Password: "Password1",
EmailVerified: true,
}
guest, err := th.App.CreateGuest(guest)
guest, err := th.App.CreateGuest(th.Context, guest)
require.Nil(t, err)
th.LoginSystemAdminWithClient(th.SystemAdminClient)
@@ -3533,9 +3533,9 @@ func TestChannelMembersMinusGroupMembers(t *testing.T) {
channel := th.CreatePrivateChannel()
_, err := th.App.AddChannelMember(user1.Id, channel, app.ChannelMemberOpts{})
_, err := th.App.AddChannelMember(th.Context, user1.Id, channel, app.ChannelMemberOpts{})
require.Nil(t, err)
_, err = th.App.AddChannelMember(user2.Id, channel, app.ChannelMemberOpts{})
_, err = th.App.AddChannelMember(th.Context, user2.Id, channel, app.ChannelMemberOpts{})
require.Nil(t, err)
channel.GroupConstrained = model.NewBool(true)