[MM-54434] Use job.Logger to capture ldap logs (#24493)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
afaf41b587
Коммит
aad25be4e1
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
)
|
||||
|
||||
const PluginIdGithub = "github"
|
||||
@@ -21,29 +20,26 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
t.Run("no error sending non trial upgrade post when no notifications are available", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
err := th.App.SendNotifyAdminPosts(ctx, "", "", false)
|
||||
err := th.App.SendNotifyAdminPosts(th.Context, "", "", false)
|
||||
require.Nil(t, err)
|
||||
})
|
||||
|
||||
t.Run("no error sending trial upgrade post when no notifications are available", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
err := th.App.SendNotifyAdminPosts(ctx, "", "", true)
|
||||
err := th.App.SendNotifyAdminPosts(th.Context, "", "", true)
|
||||
require.Nil(t, err)
|
||||
})
|
||||
|
||||
t.Run("successfully send upgrade notification", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
@@ -62,7 +58,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "test", "", false)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "test", "", false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
bot, appErr := th.App.GetSystemBot()
|
||||
@@ -97,7 +93,6 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
t.Run("successfully send trial upgrade notification", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
@@ -110,7 +105,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "test", "", true)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "test", "", true)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
bot, appErr := th.App.GetSystemBot()
|
||||
@@ -145,7 +140,6 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
t.Run("successfully send install plugin notification", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
// some notifications
|
||||
_, appErr := th.App.SaveAdminNotifyData(&model.NotifyAdminData{
|
||||
@@ -156,7 +150,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "", "", false)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "", "", false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
bot, appErr := th.App.GetSystemBot()
|
||||
@@ -190,7 +184,6 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
t.Run("persist notify admin data after sending the install plugin notification", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
// some notifications
|
||||
_, appErr := th.App.SaveAdminNotifyData(&model.NotifyAdminData{
|
||||
@@ -201,7 +194,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "", "", false)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "", "", false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
bot, appErr := th.App.GetSystemBot()
|
||||
@@ -260,7 +253,6 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
t.Run("error when trying to send upgrade post before end of cool off period", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
@@ -272,7 +264,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "", "", false)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "", "", false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
// add some more notifications while in cool off
|
||||
@@ -284,7 +276,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
require.Nil(t, appErr)
|
||||
|
||||
// second time trying to notify is forbidden
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "", "", false)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "", "", false)
|
||||
require.NotNil(t, appErr)
|
||||
require.Equal(t, appErr.Error(), "SendNotifyAdminPosts: Unable to send notification post., Cannot notify yet")
|
||||
})
|
||||
@@ -292,7 +284,6 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
t.Run("can send upgrade post at the end of cool off period", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
@@ -307,7 +298,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "", "", false)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "", "", false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
// add some more notifications while in cool off
|
||||
@@ -321,14 +312,13 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
// no error sending second time
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "", "", false)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "", "", false)
|
||||
require.Nil(t, appErr)
|
||||
})
|
||||
|
||||
t.Run("can filter notifications when plan changes within cool off period", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
@@ -349,7 +339,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "test", model.LicenseShortSkuProfessional, false) // try and send notification but workspace currentSKU has since changed to cloud-professional
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "test", model.LicenseShortSkuProfessional, false) // try and send notification but workspace currentSKU has since changed to cloud-professional
|
||||
require.Nil(t, appErr)
|
||||
|
||||
bot, appErr := th.App.GetSystemBot()
|
||||
@@ -384,7 +374,6 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
t.Run("correctly send upgrade and install plugin post with the correct user request", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
ctx := request.EmptyContext(th.TestLogger)
|
||||
|
||||
os.Setenv("MM_NOTIFY_ADMIN_COOL_OFF_DAYS", "0")
|
||||
defer os.Unsetenv("MM_NOTIFY_ADMIN_COOL_OFF_DAYS")
|
||||
@@ -399,7 +388,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
Trial: false,
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "test", "", false)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "test", "", false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
// some notifications
|
||||
@@ -410,7 +399,7 @@ func Test_SendNotifyAdminPosts(t *testing.T) {
|
||||
Trial: false,
|
||||
})
|
||||
require.Nil(t, appErr)
|
||||
appErr = th.App.SendNotifyAdminPosts(ctx, "test", "", false)
|
||||
appErr = th.App.SendNotifyAdminPosts(th.Context, "test", "", false)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
bot, appErr := th.App.GetSystemBot()
|
||||
|
||||
Ссылка в новой задаче
Block a user