Remove global app references (#7433)
* remove global app references * test fix * fix api4 test compilation
Этот коммит содержится в:
@@ -8,8 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPermanentDeleteChannel(t *testing.T) {
|
||||
a := Global()
|
||||
th := a.Setup().InitBasic()
|
||||
th := Setup().InitBasic()
|
||||
|
||||
incomingWasEnabled := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
outgoingWasEnabled := utils.Cfg.ServiceSettings.EnableOutgoingWebhooks
|
||||
@@ -20,25 +19,25 @@ func TestPermanentDeleteChannel(t *testing.T) {
|
||||
utils.Cfg.ServiceSettings.EnableOutgoingWebhooks = outgoingWasEnabled
|
||||
}()
|
||||
|
||||
channel, err := a.CreateChannel(&model.Channel{DisplayName: "deletion-test", Name: "deletion-test", Type: model.CHANNEL_OPEN, TeamId: th.BasicTeam.Id}, false)
|
||||
channel, err := th.App.CreateChannel(&model.Channel{DisplayName: "deletion-test", Name: "deletion-test", Type: model.CHANNEL_OPEN, TeamId: th.BasicTeam.Id}, false)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
defer func() {
|
||||
a.PermanentDeleteChannel(channel)
|
||||
th.App.PermanentDeleteChannel(channel)
|
||||
}()
|
||||
|
||||
incoming, err := a.CreateIncomingWebhookForChannel(th.BasicUser.Id, channel, &model.IncomingWebhook{ChannelId: channel.Id})
|
||||
incoming, err := th.App.CreateIncomingWebhookForChannel(th.BasicUser.Id, channel, &model.IncomingWebhook{ChannelId: channel.Id})
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
defer a.DeleteIncomingWebhook(incoming.Id)
|
||||
defer th.App.DeleteIncomingWebhook(incoming.Id)
|
||||
|
||||
if incoming, err = a.GetIncomingWebhook(incoming.Id); incoming == nil || err != nil {
|
||||
if incoming, err = th.App.GetIncomingWebhook(incoming.Id); incoming == nil || err != nil {
|
||||
t.Fatal("unable to get new incoming webhook")
|
||||
}
|
||||
|
||||
outgoing, err := a.CreateOutgoingWebhook(&model.OutgoingWebhook{
|
||||
outgoing, err := th.App.CreateOutgoingWebhook(&model.OutgoingWebhook{
|
||||
ChannelId: channel.Id,
|
||||
TeamId: channel.TeamId,
|
||||
CreatorId: th.BasicUser.Id,
|
||||
@@ -47,65 +46,64 @@ func TestPermanentDeleteChannel(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
defer a.DeleteOutgoingWebhook(outgoing.Id)
|
||||
defer th.App.DeleteOutgoingWebhook(outgoing.Id)
|
||||
|
||||
if outgoing, err = a.GetOutgoingWebhook(outgoing.Id); outgoing == nil || err != nil {
|
||||
if outgoing, err = th.App.GetOutgoingWebhook(outgoing.Id); outgoing == nil || err != nil {
|
||||
t.Fatal("unable to get new outgoing webhook")
|
||||
}
|
||||
|
||||
if err := a.PermanentDeleteChannel(channel); err != nil {
|
||||
if err := th.App.PermanentDeleteChannel(channel); err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
|
||||
if incoming, err = a.GetIncomingWebhook(incoming.Id); incoming != nil || err == nil {
|
||||
if incoming, err = th.App.GetIncomingWebhook(incoming.Id); incoming != nil || err == nil {
|
||||
t.Error("incoming webhook wasn't deleted")
|
||||
}
|
||||
|
||||
if outgoing, err = a.GetOutgoingWebhook(outgoing.Id); outgoing != nil || err == nil {
|
||||
if outgoing, err = th.App.GetOutgoingWebhook(outgoing.Id); outgoing != nil || err == nil {
|
||||
t.Error("outgoing webhook wasn't deleted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMoveChannel(t *testing.T) {
|
||||
a := Global()
|
||||
th := a.Setup().InitBasic()
|
||||
th := Setup().InitBasic()
|
||||
|
||||
sourceTeam := th.CreateTeam()
|
||||
targetTeam := th.CreateTeam()
|
||||
channel1 := th.CreateChannel(sourceTeam)
|
||||
defer func() {
|
||||
a.PermanentDeleteChannel(channel1)
|
||||
a.PermanentDeleteTeam(sourceTeam)
|
||||
a.PermanentDeleteTeam(targetTeam)
|
||||
th.App.PermanentDeleteChannel(channel1)
|
||||
th.App.PermanentDeleteTeam(sourceTeam)
|
||||
th.App.PermanentDeleteTeam(targetTeam)
|
||||
}()
|
||||
|
||||
if _, err := a.AddUserToTeam(sourceTeam.Id, th.BasicUser.Id, ""); err != nil {
|
||||
if _, err := th.App.AddUserToTeam(sourceTeam.Id, th.BasicUser.Id, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := a.AddUserToTeam(sourceTeam.Id, th.BasicUser2.Id, ""); err != nil {
|
||||
if _, err := th.App.AddUserToTeam(sourceTeam.Id, th.BasicUser2.Id, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := a.AddUserToTeam(targetTeam.Id, th.BasicUser.Id, ""); err != nil {
|
||||
if _, err := th.App.AddUserToTeam(targetTeam.Id, th.BasicUser.Id, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := a.AddUserToChannel(th.BasicUser, channel1); err != nil {
|
||||
if _, err := th.App.AddUserToChannel(th.BasicUser, channel1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := a.AddUserToChannel(th.BasicUser2, channel1); err != nil {
|
||||
if _, err := th.App.AddUserToChannel(th.BasicUser2, channel1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := a.MoveChannel(targetTeam, channel1); err == nil {
|
||||
if err := th.App.MoveChannel(targetTeam, channel1); err == nil {
|
||||
t.Fatal("Should have failed due to mismatched members.")
|
||||
}
|
||||
|
||||
if _, err := a.AddUserToTeam(targetTeam.Id, th.BasicUser2.Id, ""); err != nil {
|
||||
if _, err := th.App.AddUserToTeam(targetTeam.Id, th.BasicUser2.Id, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := a.MoveChannel(targetTeam, channel1); err != nil {
|
||||
if err := th.App.MoveChannel(targetTeam, channel1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user