MM-43145: channels loader (#19957)
Add channels dataloader https://mattermost.atlassian.net/browse/MM-43145 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4b354685e9
Коммит
d1de4857aa
@@ -72,6 +72,7 @@ func TestChannelStore(t *testing.T, ss store.Store, s SqlStore) {
|
||||
t.Run("Update", func(t *testing.T) { testChannelStoreUpdate(t, ss) })
|
||||
t.Run("GetChannelUnread", func(t *testing.T) { testGetChannelUnread(t, ss) })
|
||||
t.Run("Get", func(t *testing.T) { testChannelStoreGet(t, ss, s) })
|
||||
t.Run("GetMany", func(t *testing.T) { testChannelStoreGetMany(t, ss, s) })
|
||||
t.Run("GetChannelsByIds", func(t *testing.T) { testChannelStoreGetChannelsByIds(t, ss) })
|
||||
t.Run("GetChannelsWithTeamDataByIds", func(t *testing.T) { testGetChannelsWithTeamDataByIds(t, ss) })
|
||||
t.Run("GetForPost", func(t *testing.T) { testChannelStoreGetForPost(t, ss) })
|
||||
@@ -476,6 +477,40 @@ func testChannelStoreGet(t *testing.T, ss store.Store, s SqlStore) {
|
||||
s.GetMasterX().Exec("TRUNCATE Channels")
|
||||
}
|
||||
|
||||
func testChannelStoreGetMany(t *testing.T, ss store.Store, s SqlStore) {
|
||||
o1, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: model.NewId(),
|
||||
DisplayName: "Name",
|
||||
Name: NewTestId(),
|
||||
Type: model.ChannelTypeOpen,
|
||||
}, -1)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
o2, nErr := ss.Channel().Save(&model.Channel{
|
||||
TeamId: model.NewId(),
|
||||
DisplayName: "Name2",
|
||||
Name: NewTestId(),
|
||||
Type: model.ChannelTypeOpen,
|
||||
}, -1)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
res, err := ss.Channel().GetMany([]string{o1.Id, o2.Id}, true)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, res, 2)
|
||||
|
||||
res, err = ss.Channel().GetMany([]string{o1.Id, "notexists"}, true)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, res, 1)
|
||||
|
||||
_, err = ss.Channel().GetMany([]string{"notexists"}, true)
|
||||
require.Error(t, err)
|
||||
var nfErr *store.ErrNotFound
|
||||
require.True(t, errors.As(err, &nfErr))
|
||||
|
||||
// Manually truncate Channels table until testlib can handle cleanups
|
||||
s.GetMasterX().Exec("TRUNCATE Channels")
|
||||
}
|
||||
|
||||
func testChannelStoreGetChannelsByIds(t *testing.T, ss store.Store) {
|
||||
o1 := model.Channel{}
|
||||
o1.TeamId = model.NewId()
|
||||
|
||||
@@ -925,29 +925,6 @@ func (_m *ChannelStore) GetForPost(postID string) (*model.Channel, error) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetFromMaster provides a mock function with given fields: id
|
||||
func (_m *ChannelStore) GetFromMaster(id string) (*model.Channel, error) {
|
||||
ret := _m.Called(id)
|
||||
|
||||
var r0 *model.Channel
|
||||
if rf, ok := ret.Get(0).(func(string) *model.Channel); ok {
|
||||
r0 = rf(id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.Channel)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetGuestCount provides a mock function with given fields: channelID, allowFromCache
|
||||
func (_m *ChannelStore) GetGuestCount(channelID string, allowFromCache bool) (int64, error) {
|
||||
ret := _m.Called(channelID, allowFromCache)
|
||||
@@ -969,6 +946,29 @@ func (_m *ChannelStore) GetGuestCount(channelID string, allowFromCache bool) (in
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetMany provides a mock function with given fields: ids, allowFromCache
|
||||
func (_m *ChannelStore) GetMany(ids []string, allowFromCache bool) (model.ChannelList, error) {
|
||||
ret := _m.Called(ids, allowFromCache)
|
||||
|
||||
var r0 model.ChannelList
|
||||
if rf, ok := ret.Get(0).(func([]string, bool) model.ChannelList); ok {
|
||||
r0 = rf(ids, allowFromCache)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(model.ChannelList)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func([]string, bool) error); ok {
|
||||
r1 = rf(ids, allowFromCache)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetMember provides a mock function with given fields: ctx, channelID, userID
|
||||
func (_m *ChannelStore) GetMember(ctx context.Context, channelID string, userID string) (*model.ChannelMember, error) {
|
||||
ret := _m.Called(ctx, channelID, userID)
|
||||
|
||||
Ссылка в новой задаче
Block a user