Этот коммит содержится в:
Vishal
2022-10-31 19:26:04 +05:30
коммит произвёл GitHub
родитель c6b6b3313e
Коммит ecc07a3911
2 изменённых файлов: 51 добавлений и 20 удалений

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

@@ -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,6 +2857,7 @@ func TestGetLastAccessiblePostTime(t *testing.T) {
} }
func TestComputeLastAccessiblePostTime(t *testing.T) { func TestComputeLastAccessiblePostTime(t *testing.T) {
t.Run("Updates the time, if cloud limit is applicable", func(t *testing.T) {
th := SetupWithStoreMock(t) th := SetupWithStoreMock(t)
defer th.TearDown() defer th.TearDown()
@@ -2865,6 +2866,7 @@ func TestComputeLastAccessiblePostTime(t *testing.T) {
cloud := &eMocks.CloudInterface{} cloud := &eMocks.CloudInterface{}
th.App.Srv().Cloud = cloud th.App.Srv().Cloud = cloud
// cloud-starter, limit is applicable
cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{ cloud.Mock.On("GetCloudLimits", mock.Anything).Return(&model.ProductLimits{
Messages: &model.MessagesLimits{ Messages: &model.MessagesLimits{
History: model.NewInt(1), History: model.NewInt(1),
@@ -2883,6 +2885,30 @@ func TestComputeLastAccessiblePostTime(t *testing.T) {
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) {