From fab2e349b31047a04ad1b302780c4ef07d7b3f0c Mon Sep 17 00:00:00 2001 From: Shota Gvinepadze Date: Fri, 17 May 2019 00:04:58 +0400 Subject: [PATCH] [MM-10768] Migrate "Channel.SaveDirectChannel" to Sync by default (#10846) --- app/channel.go | 12 ++- app/import.go | 6 +- app/import_functions.go | 4 +- store/sqlstore/channel_store.go | 112 +++++++++++++------------- store/store.go | 4 +- store/storetest/channel_store.go | 65 ++++++++------- store/storetest/compliance_store.go | 7 +- store/storetest/mocks/ChannelStore.go | 38 ++++++--- store/storetest/post_store.go | 9 ++- store/storetest/user_store.go | 2 +- 10 files changed, 139 insertions(+), 120 deletions(-) diff --git a/app/channel.go b/app/channel.go index 8a0f38120a..ded0d94601 100644 --- a/app/channel.go +++ b/app/channel.go @@ -340,16 +340,14 @@ func (a *App) createDirectChannel(userId string, otherUserId string) (*model.Cha return nil, model.NewAppError("CreateDirectChannel", "api.channel.create_direct_channel.invalid_user.app_error", nil, otherUserId, http.StatusBadRequest) } - result := <-a.Srv.Store.Channel().CreateDirectChannel(userId, otherUserId) - if result.Err != nil { - if result.Err.Id == store.CHANNEL_EXISTS_ERROR { - return result.Data.(*model.Channel), result.Err + channel, err := a.Srv.Store.Channel().CreateDirectChannel(userId, otherUserId) + if err != nil { + if err.Id == store.CHANNEL_EXISTS_ERROR { + return channel, err } - return nil, result.Err + return nil, err } - channel := result.Data.(*model.Channel) - if result := <-a.Srv.Store.ChannelMemberHistory().LogJoinEvent(userId, channel.Id, model.GetMillis()); result.Err != nil { mlog.Warn(fmt.Sprintf("Failed to update ChannelMemberHistory table %v", result.Err)) } diff --git a/app/import.go b/app/import.go index d86b239f2a..1867f5d3c5 100644 --- a/app/import.go +++ b/app/import.go @@ -56,9 +56,9 @@ func (a *App) BulkImport(fileReader io.Reader, dryRun bool, workers int) (*model } if lineNumber == 1 { - importDataFileVersion, apperr := processImportDataFileVersionLine(line) - if apperr != nil { - return apperr, lineNumber + importDataFileVersion, appErr := processImportDataFileVersionLine(line) + if appErr != nil { + return appErr, lineNumber } if importDataFileVersion != 1 { diff --git a/app/import_functions.go b/app/import_functions.go index 240c914437..c98f995611 100644 --- a/app/import_functions.go +++ b/app/import_functions.go @@ -1136,8 +1136,8 @@ func (a *App) ImportDirectChannel(data *DirectChannelImportData, dryRun bool) *m if data.Header != nil { channel.Header = *data.Header - if _, apperr := a.Srv.Store.Channel().Update(channel); apperr != nil { - return model.NewAppError("BulkImport", "app.import.import_direct_channel.update_header_failed.error", nil, apperr.Error(), http.StatusBadRequest) + if _, appErr := a.Srv.Store.Channel().Update(channel); appErr != nil { + return model.NewAppError("BulkImport", "app.import.import_direct_channel.update_header_failed.error", nil, appErr.Error(), http.StatusBadRequest) } } diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index d719db4a58..ce018b3f8a 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -487,7 +487,7 @@ func (s SqlChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) }) } -func (s SqlChannelStore) CreateDirectChannel(userId string, otherUserId string) store.StoreChannel { +func (s SqlChannelStore) CreateDirectChannel(userId string, otherUserId string) (*model.Channel, *model.AppError) { channel := new(model.Channel) channel.DisplayName = "" @@ -510,64 +510,62 @@ func (s SqlChannelStore) CreateDirectChannel(userId string, otherUserId string) return s.SaveDirectChannel(channel, cm1, cm2) } -func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) store.StoreChannel { - return store.Do(func(result *store.StoreResult) { - if directchannel.DeleteAt != 0 { - result.Err = model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save.archived_channel.app_error", nil, "", http.StatusBadRequest) - return +func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, *model.AppError) { + if directchannel.DeleteAt != 0 { + return nil, model.NewAppError("SqlChannelStore.Save", "store.sql_channel.save.archived_channel.app_error", nil, "", http.StatusBadRequest) + } + + if directchannel.Type != model.CHANNEL_DIRECT { + return nil, model.NewAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.not_direct.app_error", nil, "", http.StatusBadRequest) + } + + transaction, err := s.GetMaster().Begin() + if err != nil { + return nil, model.NewAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) + } + defer finalizeTransaction(transaction) + + directchannel.TeamId = "" + // After updating saveChannelT() should be: + // newChannel, appErr := s.saveChannelT(transaction, directchannel, 0) + channelResult := s.saveChannelT(transaction, directchannel, 0) + var newChannel *model.Channel + if channelResult.Data != nil { + newChannel = channelResult.Data.(*model.Channel) + } + appErr := channelResult.Err + + if appErr != nil { + return newChannel, appErr + } + + // Members need new channel ID + member1.ChannelId = newChannel.Id + member2.ChannelId = newChannel.Id + + member1Result := s.saveMemberT(transaction, member1, newChannel) + member2Result := member1Result + if member1.UserId != member2.UserId { + member2Result = s.saveMemberT(transaction, member2, newChannel) + } + + if member1Result.Err != nil || member2Result.Err != nil { + details := "" + if member1Result.Err != nil { + details += "Member1Err: " + member1Result.Err.Message } - - if directchannel.Type != model.CHANNEL_DIRECT { - result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.not_direct.app_error", nil, "", http.StatusBadRequest) - return + if member2Result.Err != nil { + details += "Member2Err: " + member2Result.Err.Message } + return nil, model.NewAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.add_members.app_error", nil, details, http.StatusInternalServerError) + } - transaction, err := s.GetMaster().Begin() - if err != nil { - result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) - return - } - defer finalizeTransaction(transaction) + if err := transaction.Commit(); err != nil { + return nil, model.NewAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.commit.app_error", nil, err.Error(), http.StatusInternalServerError) + } - directchannel.TeamId = "" - channelResult := s.saveChannelT(transaction, directchannel, 0) + return newChannel, nil - if channelResult.Err != nil { - result.Err = channelResult.Err - result.Data = channelResult.Data - return - } - - newChannel := channelResult.Data.(*model.Channel) - // Members need new channel ID - member1.ChannelId = newChannel.Id - member2.ChannelId = newChannel.Id - - member1Result := s.saveMemberT(transaction, member1, newChannel) - member2Result := member1Result - if member1.UserId != member2.UserId { - member2Result = s.saveMemberT(transaction, member2, newChannel) - } - - if member1Result.Err != nil || member2Result.Err != nil { - details := "" - if member1Result.Err != nil { - details += "Member1Err: " + member1Result.Err.Message - } - if member2Result.Err != nil { - details += "Member2Err: " + member2Result.Err.Message - } - result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.add_members.app_error", nil, details, http.StatusInternalServerError) - return - } - - if err := transaction.Commit(); err != nil { - result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "store.sql_channel.save_direct_channel.commit.app_error", nil, err.Error(), http.StatusInternalServerError) - return - } - - *result = channelResult - }) } func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *model.Channel, maxChannelsPerTeam int64) store.StoreResult { @@ -621,9 +619,9 @@ func (s SqlChannelStore) Update(channel *model.Channel) (*model.Channel, *model. } defer finalizeTransaction(transaction) - updatedChannel, apperr := s.updateChannelT(transaction, channel) - if apperr != nil { - return nil, apperr + updatedChannel, appErr := s.updateChannelT(transaction, channel) + if appErr != nil { + return nil, appErr } // Additionally propagate the write to the PublicChannels table. diff --git a/store/store.go b/store/store.go index 56f1f0f973..f43c0e2c76 100644 --- a/store/store.go +++ b/store/store.go @@ -130,8 +130,8 @@ type TeamStore interface { type ChannelStore interface { Save(channel *model.Channel, maxChannelsPerTeam int64) StoreChannel - CreateDirectChannel(userId string, otherUserId string) StoreChannel - SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel + CreateDirectChannel(userId string, otherUserId string) (*model.Channel, *model.AppError) + SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, *model.AppError) Update(channel *model.Channel) (*model.Channel, *model.AppError) Get(id string, allowFromCache bool) (*model.Channel, *model.AppError) InvalidateChannel(id string) diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index 076faaa6d0..6fda98957f 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -149,7 +149,7 @@ func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlSuppli m2.UserId = u2.Id m2.NotifyProps = model.GetDefaultChannelNotifyProps() - if err := (<-ss.Channel().SaveDirectChannel(&o1, &m1, &m2)).Err; err != nil { + if _, err := ss.Channel().SaveDirectChannel(&o1, &m1, &m2); err != nil { t.Fatal("couldn't save direct channel", err) } @@ -158,7 +158,7 @@ func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlSuppli t.Fatal("should have saved 2 members") } - if err := (<-ss.Channel().SaveDirectChannel(&o1, &m1, &m2)).Err; err == nil { + if _, err := ss.Channel().SaveDirectChannel(&o1, &m1, &m2); err == nil { t.Fatal("shouldn't be able to update from save") } @@ -170,11 +170,12 @@ func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlSuppli Type: o1.Type, } - if result := <-ss.Channel().SaveDirectChannel(&o1a, &m1, &m2); result.Err == nil { + returnedChannel, err := ss.Channel().SaveDirectChannel(&o1a, &m1, &m2) + if err == nil { t.Fatal("should've failed to save a duplicate direct channel") - } else if result.Err.Id != store.CHANNEL_EXISTS_ERROR { + } else if err.Id != store.CHANNEL_EXISTS_ERROR { t.Fatal("should've returned CHANNEL_EXISTS_ERROR") - } else if returned := result.Data.(*model.Channel); returned.Id != o1.Id { + } else if returnedChannel.Id != o1.Id { t.Fatal("should've returned original channel when saving a duplicate direct channel") } @@ -182,7 +183,7 @@ func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlSuppli o1.Id = "" o1.Name = "zz" + model.NewId() + "b" o1.Type = model.CHANNEL_OPEN - if err := (<-ss.Channel().SaveDirectChannel(&o1, &m1, &m2)).Err; err == nil { + if _, err := ss.Channel().SaveDirectChannel(&o1, &m1, &m2); err == nil { t.Fatal("Should not be able to save non-direct channel") } @@ -191,7 +192,7 @@ func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store, s SqlSuppli o1.DisplayName = "Myself" o1.Name = "zz" + model.NewId() + "b" o1.Type = model.CHANNEL_DIRECT - if err := (<-ss.Channel().SaveDirectChannel(&o1, &m1, &m1)).Err; err != nil { + if _, err := ss.Channel().SaveDirectChannel(&o1, &m1, &m1); err != nil { t.Fatal("couldn't save direct channel", err) } @@ -217,11 +218,10 @@ func testChannelStoreCreateDirectChannel(t *testing.T, ss store.Store) { store.Must(ss.User().Save(u2)) store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1)) - res := <-ss.Channel().CreateDirectChannel(u1.Id, u2.Id) - if res.Err != nil { - t.Fatal("couldn't create direct channel", res.Err) + c1, err := ss.Channel().CreateDirectChannel(u1.Id, u2.Id) + if err != nil { + t.Fatal("couldn't create direct channel", err) } - c1 := res.Data.(*model.Channel) defer func() { <-ss.Channel().PermanentDeleteMembersByChannel(c1.Id) <-ss.Channel().PermanentDelete(c1.Id) @@ -394,7 +394,8 @@ func testChannelStoreGet(t *testing.T, ss store.Store, s SqlSupplier) { m2.UserId = u2.Id m2.NotifyProps = model.GetDefaultChannelNotifyProps() - store.Must(ss.Channel().SaveDirectChannel(&o2, &m1, &m2)) + _, err := ss.Channel().SaveDirectChannel(&o2, &m1, &m2) + require.Nil(t, err) if c2, err := ss.Channel().Get(o2.Id, false); err != nil { t.Fatal(err) @@ -469,7 +470,8 @@ func testChannelStoreGetChannelsByIds(t *testing.T, ss store.Store) { m2.UserId = u2.Id m2.NotifyProps = model.GetDefaultChannelNotifyProps() - store.Must(ss.Channel().SaveDirectChannel(&o2, &m1, &m2)) + _, err := ss.Channel().SaveDirectChannel(&o2, &m1, &m2) + require.Nil(t, err) if r1 := <-ss.Channel().GetChannelsByIds([]string{o1.Id, o2.Id}); r1.Err != nil { t.Fatal(r1.Err) @@ -1089,7 +1091,8 @@ func testChannelStoreGetAllChannels(t *testing.T, ss store.Store, s SqlSupplier) c3.Type = model.CHANNEL_PRIVATE store.Must(ss.Channel().Save(&c3, -1)) - store.Must(ss.Channel().CreateDirectChannel(model.NewId(), model.NewId())) + _, err = ss.Channel().CreateDirectChannel(model.NewId(), model.NewId()) + require.Nil(t, err) userIds := []string{model.NewId(), model.NewId(), model.NewId()} @@ -2494,8 +2497,10 @@ func testChannelStoreAutocompleteInTeamForSearch(t *testing.T, ss store.Store, s o5.Type = model.CHANNEL_PRIVATE store.Must(ss.Channel().Save(&o5, -1)) - store.Must(ss.Channel().CreateDirectChannel(u1.Id, u2.Id)) - store.Must(ss.Channel().CreateDirectChannel(u2.Id, u3.Id)) + _, err = ss.Channel().CreateDirectChannel(u1.Id, u2.Id) + require.Nil(t, err) + _, err = ss.Channel().CreateDirectChannel(u2.Id, u3.Id) + require.Nil(t, err) tt := []struct { name string @@ -2601,11 +2606,9 @@ func testChannelStoreAnalyticsDeletedTypeCount(t *testing.T, ss store.Store) { u2.Nickname = model.NewId() store.Must(ss.User().Save(u2)) - var d4 *model.Channel - if result := <-ss.Channel().CreateDirectChannel(u1.Id, u2.Id); result.Err != nil { - t.Fatalf(result.Err.Error()) - } else { - d4 = result.Data.(*model.Channel) + d4, err := ss.Channel().CreateDirectChannel(u1.Id, u2.Id) + if err != nil { + t.Fatalf(err.Error()) } defer func() { <-ss.Channel().PermanentDeleteMembersByChannel(d4.Id) @@ -2633,7 +2636,7 @@ func testChannelStoreAnalyticsDeletedTypeCount(t *testing.T, ss store.Store) { directStartCount = result.Data.(int64) } - err := ss.Channel().Delete(o1.Id, model.GetMillis()) + err = ss.Channel().Delete(o1.Id, model.GetMillis()) require.Nil(t, err, "channel should have been deleted") err = ss.Channel().Delete(o2.Id, model.GetMillis()) require.Nil(t, err, "channel should have been deleted") @@ -3015,8 +3018,8 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlSupplier) }) o2.Type = model.CHANNEL_PRIVATE - _, apperr := ss.Channel().Update(&o2) - require.Nil(t, apperr) + _, appErr := ss.Channel().Update(&o2) + require.Nil(t, appErr) t.Run("o2 no longer listed since now private", func(t *testing.T) { result := <-ss.Channel().SearchInTeam(teamId, "", true) @@ -3025,8 +3028,8 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlSupplier) }) o2.Type = model.CHANNEL_OPEN - _, apperr = ss.Channel().Update(&o2) - require.Nil(t, apperr) + _, appErr = ss.Channel().Update(&o2) + require.Nil(t, appErr) t.Run("o2 listed once again since now public", func(t *testing.T) { result := <-ss.Channel().SearchInTeam(teamId, "", true) @@ -3111,8 +3114,8 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlSupplier) require.Nil(t, err) o4.DisplayName += " - Modified" - _, apperr = ss.Channel().Update(&o4) - require.Nil(t, apperr) + _, appErr = ss.Channel().Update(&o4) + require.Nil(t, appErr) t.Run("verify o4 UPDATE converted to INSERT", func(t *testing.T) { result := <-ss.Channel().SearchInTeam(teamId, "", true) @@ -3318,7 +3321,7 @@ func testChannelStoreExportAllDirectChannels(t *testing.T, ss store.Store, s Sql m2.UserId = u2.Id m2.NotifyProps = model.GetDefaultChannelNotifyProps() - <-ss.Channel().SaveDirectChannel(&o1, &m1, &m2) + ss.Channel().SaveDirectChannel(&o1, &m1, &m2) r1 := <-ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26)) assert.Nil(t, r1.Err) @@ -3376,7 +3379,7 @@ func testChannelStoreExportAllDirectChannelsExcludePrivateAndPublic(t *testing.T m2.UserId = u2.Id m2.NotifyProps = model.GetDefaultChannelNotifyProps() - <-ss.Channel().SaveDirectChannel(&o1, &m1, &m2) + ss.Channel().SaveDirectChannel(&o1, &m1, &m2) r1 := <-ss.Channel().GetAllDirectChannelsForExportAfter(10000, strings.Repeat("0", 26)) assert.Nil(t, r1.Err) @@ -3419,7 +3422,7 @@ func testChannelStoreExportAllDirectChannelsDeletedChannel(t *testing.T, ss stor m2.UserId = u2.Id m2.NotifyProps = model.GetDefaultChannelNotifyProps() - _ = <-ss.Channel().SaveDirectChannel(&o1, &m1, &m2) + ss.Channel().SaveDirectChannel(&o1, &m1, &m2) o1.DeleteAt = 1 err := ss.Channel().SetDeleteAt(o1.Id, 1, 1) diff --git a/store/storetest/compliance_store.go b/store/storetest/compliance_store.go index 71154184ba..72f9db69fb 100644 --- a/store/storetest/compliance_store.go +++ b/store/storetest/compliance_store.go @@ -192,8 +192,8 @@ func testComplianceExportDirectMessages(t *testing.T, ss store.Store) { c1.Type = model.CHANNEL_OPEN c1 = store.Must(ss.Channel().Save(c1, -1)).(*model.Channel) - cDM := store.Must(ss.Channel().CreateDirectChannel(u1.Id, u2.Id)).(*model.Channel) - + cDM, err := ss.Channel().CreateDirectChannel(u1.Id, u2.Id) + require.Nil(t, err) o1 := &model.Post{} o1.ChannelId = c1.Id o1.UserId = u1.Id @@ -470,7 +470,8 @@ func testMessageExportDirectMessageChannel(t *testing.T, ss store.Store) { }, -1)) // as well as a DM channel between those users - directMessageChannel := store.Must(ss.Channel().CreateDirectChannel(user1.Id, user2.Id)).(*model.Channel) + directMessageChannel, err := ss.Channel().CreateDirectChannel(user1.Id, user2.Id) + require.Nil(t, err) // user1 also sends a DM to user2 post := &model.Post{ diff --git a/store/storetest/mocks/ChannelStore.go b/store/storetest/mocks/ChannelStore.go index 3309ae62a3..9c92634405 100644 --- a/store/storetest/mocks/ChannelStore.go +++ b/store/storetest/mocks/ChannelStore.go @@ -99,19 +99,28 @@ func (_m *ChannelStore) ClearCaches() { } // CreateDirectChannel provides a mock function with given fields: userId, otherUserId -func (_m *ChannelStore) CreateDirectChannel(userId string, otherUserId string) store.StoreChannel { +func (_m *ChannelStore) CreateDirectChannel(userId string, otherUserId string) (*model.Channel, *model.AppError) { ret := _m.Called(userId, otherUserId) - var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func(string, string) store.StoreChannel); ok { + var r0 *model.Channel + if rf, ok := ret.Get(0).(func(string, string) *model.Channel); ok { r0 = rf(userId, otherUserId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(store.StoreChannel) + r0 = ret.Get(0).(*model.Channel) } } - return r0 + var r1 *model.AppError + if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { + r1 = rf(userId, otherUserId) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.AppError) + } + } + + return r0, r1 } // Delete provides a mock function with given fields: channelId, time @@ -954,19 +963,28 @@ func (_m *ChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) s } // SaveDirectChannel provides a mock function with given fields: channel, member1, member2 -func (_m *ChannelStore) SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) store.StoreChannel { +func (_m *ChannelStore) SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, *model.AppError) { ret := _m.Called(channel, member1, member2) - var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func(*model.Channel, *model.ChannelMember, *model.ChannelMember) store.StoreChannel); ok { + var r0 *model.Channel + if rf, ok := ret.Get(0).(func(*model.Channel, *model.ChannelMember, *model.ChannelMember) *model.Channel); ok { r0 = rf(channel, member1, member2) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(store.StoreChannel) + r0 = ret.Get(0).(*model.Channel) } } - return r0 + var r1 *model.AppError + if rf, ok := ret.Get(1).(func(*model.Channel, *model.ChannelMember, *model.ChannelMember) *model.AppError); ok { + r1 = rf(channel, member1, member2) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.AppError) + } + } + + return r0, r1 } // SaveMember provides a mock function with given fields: member diff --git a/store/storetest/post_store.go b/store/storetest/post_store.go index 95e53effb8..1149e3501d 100644 --- a/store/storetest/post_store.go +++ b/store/storetest/post_store.go @@ -1251,7 +1251,8 @@ func testPostStoreGetFlaggedPostsForTeam(t *testing.T, ss store.Store, s SqlSupp m2.UserId = model.NewId() m2.NotifyProps = model.GetDefaultChannelNotifyProps() - c2 = store.Must(ss.Channel().SaveDirectChannel(c2, m1, m2)).(*model.Channel) + c2, err := ss.Channel().SaveDirectChannel(c2, m1, m2) + require.Nil(t, err) o5 := &model.Post{} o5.ChannelId = c2.Id @@ -2018,7 +2019,7 @@ func testPostStoreGetDirectPostParentsForExportAfter(t *testing.T, ss store.Stor m2.UserId = u2.Id m2.NotifyProps = model.GetDefaultChannelNotifyProps() - <-ss.Channel().SaveDirectChannel(&o1, &m1, &m2) + ss.Channel().SaveDirectChannel(&o1, &m1, &m2) p1 := &model.Post{} p1.ChannelId = o1.Id @@ -2070,7 +2071,7 @@ func testPostStoreGetDirectPostParentsForExportAfterDeleted(t *testing.T, ss sto m2.UserId = u2.Id m2.NotifyProps = model.GetDefaultChannelNotifyProps() - <-ss.Channel().SaveDirectChannel(&o1, &m1, &m2) + ss.Channel().SaveDirectChannel(&o1, &m1, &m2) o1.DeleteAt = 1 err := ss.Channel().SetDeleteAt(o1.Id, 1, 1) @@ -2134,7 +2135,7 @@ func testPostStoreGetDirectPostParentsForExportAfterBatched(t *testing.T, ss sto m2.UserId = u2.Id m2.NotifyProps = model.GetDefaultChannelNotifyProps() - <-ss.Channel().SaveDirectChannel(&o1, &m1, &m2) + ss.Channel().SaveDirectChannel(&o1, &m1, &m2) p1 := &model.Post{} p1.ChannelId = o1.Id diff --git a/store/storetest/user_store.go b/store/storetest/user_store.go index cf98d8aac8..dfe63e4df0 100644 --- a/store/storetest/user_store.go +++ b/store/storetest/user_store.go @@ -1689,7 +1689,7 @@ func testUserUnreadCount(t *testing.T, ss store.Store) { m1.ChannelId = c2.Id m2.ChannelId = c2.Id - if err := (<-ss.Channel().SaveDirectChannel(&c2, &m1, &m2)).Err; err != nil { + if _, err := ss.Channel().SaveDirectChannel(&c2, &m1, &m2); err != nil { t.Fatal("couldn't save direct channel", err) }