MM-59947: Remove the remaining **model.User special casing (#28707)
We remove the remaining special casing for **model.User and add unit tests to lock in the behavior. Additional load tests were done locally to confirm there are no hidden code paths left out. https://mattermost.atlassian.net/browse/MM-59947 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bef486ab00
Коммит
a190fe8503
@@ -8,14 +8,15 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/plugin/plugintest/mock"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store/storetest"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store/storetest/mocks"
|
||||
cmocks "github.com/mattermost/mattermost/server/v8/platform/services/cache/mocks"
|
||||
)
|
||||
|
||||
func TestUserStore(t *testing.T) {
|
||||
@@ -118,6 +119,27 @@ func TestUserStoreCache(t *testing.T) {
|
||||
storedUsers[i].NotifyProps = originalProps[i]
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("assert **model.User not passed", func(t *testing.T) {
|
||||
mockStore := getMockStore(t)
|
||||
mockCacheProvider := getMockCacheProvider()
|
||||
cachedStore, err := NewLocalCacheLayer(mockStore, nil, nil, mockCacheProvider, logger)
|
||||
require.NoError(t, err)
|
||||
|
||||
cmock := cmocks.NewCache(t)
|
||||
cmock.On("GetMulti", []string{"123"}, mock.MatchedBy(func(values []any) bool {
|
||||
if len(values) != 1 {
|
||||
return false
|
||||
}
|
||||
_, ok := values[0].(*model.User)
|
||||
return ok
|
||||
})).Return(nil)
|
||||
|
||||
cachedStore.user.rootStore.userProfileByIdsCache = cmock
|
||||
|
||||
_, err = cachedStore.User().GetProfileByIds(context.Background(), fakeUserIds, &store.UserGetByIdsOpts{}, true)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestUserStoreGetAllProfiles(t *testing.T) {
|
||||
@@ -301,6 +323,21 @@ func TestUserStoreGetCache(t *testing.T) {
|
||||
|
||||
storedUser.NotifyProps = originalProps
|
||||
})
|
||||
|
||||
t.Run("assert **model.User not passed", func(t *testing.T) {
|
||||
mockStore := getMockStore(t)
|
||||
mockCacheProvider := getMockCacheProvider()
|
||||
cachedStore, err := NewLocalCacheLayer(mockStore, nil, nil, mockCacheProvider, logger)
|
||||
require.NoError(t, err)
|
||||
|
||||
cmock := cmocks.NewCache(t)
|
||||
cmock.On("Get", "123", mock.AnythingOfType("*model.User")).Return(nil)
|
||||
|
||||
cachedStore.user.rootStore.userProfileByIdsCache = cmock
|
||||
|
||||
_, err = cachedStore.User().Get(context.Background(), fakeUserId)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestUserStoreGetManyCache(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user