MM-27493 Shared channels (MVP) (#17301)
Remote Cluster Service - provides ability for multiple Mattermost cluster instances to create a trusted connection with each other and exchange messages - trusted connections are managed via slash commands (for now) - facilitates features requiring inter-cluster communication, such as Shared Channels Shared Channels Service - provides ability to shared channels between one or more Mattermost cluster instances (using trusted connection) - sharing/unsharing of channels is managed via slash commands (for now)
Этот коммит содержится в:
@@ -2053,3 +2053,87 @@ func TestReplyToPostWithLag(t *testing.T) {
|
||||
require.NotNil(t, reply)
|
||||
})
|
||||
}
|
||||
|
||||
func TestSharedChannelSyncForPostActions(t *testing.T) {
|
||||
t.Run("creating a post in a shared channel performs a content sync when sync service is running on that node", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
remoteClusterService := NewMockSharedChannelService(nil)
|
||||
th.App.srv.sharedChannelService = remoteClusterService
|
||||
testCluster := &testlib.FakeClusterInterface{}
|
||||
th.Server.Cluster = testCluster
|
||||
|
||||
user := th.BasicUser
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
|
||||
|
||||
_, err := th.App.CreatePost(&model.Post{
|
||||
UserId: user.Id,
|
||||
ChannelId: channel.Id,
|
||||
Message: "Hello folks",
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err, "Creating a post should not error")
|
||||
|
||||
assert.Len(t, remoteClusterService.notifications, 1)
|
||||
assert.Equal(t, channel.Id, remoteClusterService.notifications[0])
|
||||
})
|
||||
|
||||
t.Run("updating a post in a shared channel performs a content sync when sync service is running on that node", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
remoteClusterService := NewMockSharedChannelService(nil)
|
||||
th.App.srv.sharedChannelService = remoteClusterService
|
||||
testCluster := &testlib.FakeClusterInterface{}
|
||||
th.Server.Cluster = testCluster
|
||||
|
||||
user := th.BasicUser
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
|
||||
|
||||
post, err := th.App.CreatePost(&model.Post{
|
||||
UserId: user.Id,
|
||||
ChannelId: channel.Id,
|
||||
Message: "Hello folks",
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err, "Creating a post should not error")
|
||||
|
||||
_, err = th.App.UpdatePost(post, true)
|
||||
require.Nil(t, err, "Updating a post should not error")
|
||||
|
||||
assert.Len(t, remoteClusterService.notifications, 2)
|
||||
assert.Equal(t, channel.Id, remoteClusterService.notifications[0])
|
||||
assert.Equal(t, channel.Id, remoteClusterService.notifications[1])
|
||||
})
|
||||
|
||||
t.Run("deleting a post in a shared channel performs a content sync when sync service is running on that node", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
remoteClusterService := NewMockSharedChannelService(nil)
|
||||
th.App.srv.sharedChannelService = remoteClusterService
|
||||
testCluster := &testlib.FakeClusterInterface{}
|
||||
th.Server.Cluster = testCluster
|
||||
|
||||
user := th.BasicUser
|
||||
|
||||
channel := th.CreateChannel(th.BasicTeam, WithShared(true))
|
||||
|
||||
post, err := th.App.CreatePost(&model.Post{
|
||||
UserId: user.Id,
|
||||
ChannelId: channel.Id,
|
||||
Message: "Hello folks",
|
||||
}, channel, false, true)
|
||||
require.Nil(t, err, "Creating a post should not error")
|
||||
|
||||
_, err = th.App.DeletePost(post.Id, user.Id)
|
||||
require.Nil(t, err, "Deleting a post should not error")
|
||||
|
||||
// one creation and two deletes
|
||||
assert.Len(t, remoteClusterService.notifications, 3)
|
||||
assert.Equal(t, channel.Id, remoteClusterService.notifications[0])
|
||||
assert.Equal(t, channel.Id, remoteClusterService.notifications[1])
|
||||
assert.Equal(t, channel.Id, remoteClusterService.notifications[2])
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user