Migrates Channel.GetAllDirectChannelsForExportAfter to sync by default (#11272)

Этот коммит содержится в:
Rodrigo Villablanca Vásquez
2019-06-20 11:01:49 -04:00
коммит произвёл Gabe Jackson
родитель b1631026d8
Коммит 1e05d37290
6 изменённых файлов: 97 добавлений и 96 удалений

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

@@ -507,12 +507,11 @@ func (a *App) copyEmojiImages(emojiId string, emojiImagePath string, pathToDir s
func (a *App) ExportAllDirectChannels(writer io.Writer) *model.AppError {
afterId := strings.Repeat("0", 26)
for {
result := <-a.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, afterId)
if result.Err != nil {
return result.Err
channels, err := a.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, afterId)
if err != nil {
return err
}
channels := result.Data.([]*model.DirectChannelForExport)
if len(channels) == 0 {
break
}

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

@@ -227,8 +227,8 @@ func TestExportDMChannel(t *testing.T) {
err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir")
require.Nil(t, err)
result := <-th1.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels := result.Data.([]*model.DirectChannelForExport)
channels, err := th1.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 1, len(channels))
th1.TearDown()
@@ -236,8 +236,8 @@ func TestExportDMChannel(t *testing.T) {
th2 := Setup(t)
defer th2.TearDown()
result = <-th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels = result.Data.([]*model.DirectChannelForExport)
channels, err = th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 0, len(channels))
// import the exported channel
@@ -246,8 +246,8 @@ func TestExportDMChannel(t *testing.T) {
assert.Equal(t, 0, i)
// Ensure the Members of the imported DM channel is the same was from the exported
result = <-th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels = result.Data.([]*model.DirectChannelForExport)
channels, err = th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 1, len(channels))
assert.ElementsMatch(t, []string{th1.BasicUser.Username, th1.BasicUser2.Username}, *channels[0].Members)
}
@@ -263,15 +263,15 @@ func TestExportDMChannelToSelf(t *testing.T) {
err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir")
require.Nil(t, err)
result := <-th1.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels := result.Data.([]*model.DirectChannelForExport)
channels, err := th1.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 1, len(channels))
th2 := Setup(t)
defer th2.TearDown()
result = <-th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels = result.Data.([]*model.DirectChannelForExport)
channels, err = th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 0, len(channels))
// import the exported channel
@@ -280,8 +280,8 @@ func TestExportDMChannelToSelf(t *testing.T) {
assert.Equal(t, 0, i)
// Ensure no channels were imported
result = <-th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels = result.Data.([]*model.DirectChannelForExport)
channels, err = th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 0, len(channels))
}
@@ -300,8 +300,8 @@ func TestExportGMChannel(t *testing.T) {
err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir")
require.Nil(t, err)
result := <-th1.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels := result.Data.([]*model.DirectChannelForExport)
channels, err := th1.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 1, len(channels))
th1.TearDown()
@@ -309,8 +309,8 @@ func TestExportGMChannel(t *testing.T) {
th2 := Setup(t)
defer th2.TearDown()
result = <-th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels = result.Data.([]*model.DirectChannelForExport)
channels, err = th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 0, len(channels))
}
@@ -332,8 +332,8 @@ func TestExportGMandDMChannels(t *testing.T) {
err := th1.App.BulkExport(&b, "somefile", "somePath", "someDir")
require.Nil(t, err)
result := <-th1.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels := result.Data.([]*model.DirectChannelForExport)
channels, err := th1.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 2, len(channels))
th1.TearDown()
@@ -341,8 +341,8 @@ func TestExportGMandDMChannels(t *testing.T) {
th2 := Setup(t)
defer th2.TearDown()
result = <-th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels = result.Data.([]*model.DirectChannelForExport)
channels, err = th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
assert.Equal(t, 0, len(channels))
// import the exported channel
@@ -351,8 +351,8 @@ func TestExportGMandDMChannels(t *testing.T) {
assert.Equal(t, 0, i)
// Ensure the Members of the imported GM channel is the same was from the exported
result = <-th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
channels = result.Data.([]*model.DirectChannelForExport)
channels, err = th2.App.Srv.Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
require.Nil(t, err)
// Adding some deteminism so its possible to assert on slice index
sort.Slice(channels, func(i, j int) bool { return channels[i].Type > channels[j].Type })