fix no-cloud-limit error (#21447)
Этот коммит содержится в:
@@ -1440,6 +1440,11 @@ func (a *App) ComputeLastAccessiblePostTime() error {
|
|||||||
return appErr
|
return appErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if limit == 0 {
|
||||||
|
// Cloud limit is not applicable
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
createdAt, err := a.Srv().GetStore().Post().GetNthRecentPostTime(limit)
|
createdAt, err := a.Srv().GetStore().Post().GetNthRecentPostTime(limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var nfErr *store.ErrNotFound
|
var nfErr *store.ErrNotFound
|
||||||
|
|||||||
@@ -2857,32 +2857,58 @@ func TestGetLastAccessiblePostTime(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestComputeLastAccessiblePostTime(t *testing.T) {
|
func TestComputeLastAccessiblePostTime(t *testing.T) {
|
||||||
th := SetupWithStoreMock(t)
|
t.Run("Updates the time, if cloud limit is applicable", func(t *testing.T) {
|
||||||
defer th.TearDown()
|
th := SetupWithStoreMock(t)
|
||||||
|
defer th.TearDown()
|
||||||
|
|
||||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||||
|
|
||||||
cloud := &eMocks.CloudInterface{}
|
cloud := &eMocks.CloudInterface{}
|
||||||
th.App.Srv().Cloud = cloud
|
th.App.Srv().Cloud = cloud
|
||||||
|
|
||||||
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
|
// cloud-starter, limit is applicable
|
||||||
Messages: &model.MessagesLimits{
|
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
|
||||||
History: model.NewInt(1),
|
Messages: &model.MessagesLimits{
|
||||||
},
|
History: model.NewInt(1),
|
||||||
}, nil)
|
},
|
||||||
|
}, nil)
|
||||||
|
|
||||||
mockStore := th.App.Srv().Store().(*storemocks.Store)
|
mockStore := th.App.Srv().Store().(*storemocks.Store)
|
||||||
mockPostStore := storemocks.PostStore{}
|
mockPostStore := storemocks.PostStore{}
|
||||||
mockPostStore.On("GetNthRecentPostTime", mock.Anything).Return(int64(1), nil)
|
mockPostStore.On("GetNthRecentPostTime", mock.Anything).Return(int64(1), nil)
|
||||||
mockSystemStore := storemocks.SystemStore{}
|
mockSystemStore := storemocks.SystemStore{}
|
||||||
mockSystemStore.On("SaveOrUpdate", mock.Anything).Return(nil)
|
mockSystemStore.On("SaveOrUpdate", mock.Anything).Return(nil)
|
||||||
mockStore.On("Post").Return(&mockPostStore)
|
mockStore.On("Post").Return(&mockPostStore)
|
||||||
mockStore.On("System").Return(&mockSystemStore)
|
mockStore.On("System").Return(&mockSystemStore)
|
||||||
|
|
||||||
err := th.App.ComputeLastAccessiblePostTime()
|
err := th.App.ComputeLastAccessiblePostTime()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
mockSystemStore.AssertCalled(t, "SaveOrUpdate", mock.Anything)
|
mockSystemStore.AssertCalled(t, "SaveOrUpdate", mock.Anything)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Do NOT update the time, if cloud limit is NOT applicable", func(t *testing.T) {
|
||||||
|
th := SetupWithStoreMock(t)
|
||||||
|
defer th.TearDown()
|
||||||
|
|
||||||
|
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||||
|
|
||||||
|
cloud := &eMocks.CloudInterface{}
|
||||||
|
th.App.Srv().Cloud = cloud
|
||||||
|
|
||||||
|
// enterprise, limit is NOT applicable
|
||||||
|
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(nil, nil)
|
||||||
|
|
||||||
|
mockStore := th.App.Srv().Store().(*storemocks.Store)
|
||||||
|
mockSystemStore := storemocks.SystemStore{}
|
||||||
|
mockSystemStore.On("SaveOrUpdate", mock.Anything).Return(nil)
|
||||||
|
mockStore.On("System").Return(&mockSystemStore)
|
||||||
|
|
||||||
|
err := th.App.ComputeLastAccessiblePostTime()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
mockSystemStore.AssertNotCalled(t, "SaveOrUpdate", mock.Anything)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTopThreadsForTeamSince(t *testing.T) {
|
func TestGetTopThreadsForTeamSince(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user