mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Removed unused fields from ChannelMemberHistory table, introduced new model.ChannelMemberHistoryResult object that includes those fields that are selected from a join on other tables
This commit is contained in:
@@ -116,14 +116,14 @@ func TestJoinDefaultChannelsTownSquare(t *testing.T) {
|
||||
|
||||
// figure out the initial number of users in town square
|
||||
townSquareChannelId := store.Must(th.App.Srv.Store.Channel().GetByName(th.BasicTeam.Id, "town-square", true)).(*model.Channel).Id
|
||||
initialNumTownSquareUsers := len(store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, townSquareChannelId)).([]*model.ChannelMemberHistory))
|
||||
initialNumTownSquareUsers := len(store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, townSquareChannelId)).([]*model.ChannelMemberHistoryResult))
|
||||
|
||||
// create a new user that joins the default channels
|
||||
user := th.CreateUser()
|
||||
th.App.JoinDefaultChannels(th.BasicTeam.Id, user, model.CHANNEL_USER_ROLE_ID, "")
|
||||
|
||||
// there should be a ChannelMemberHistory record for the user
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, townSquareChannelId)).([]*model.ChannelMemberHistory)
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, townSquareChannelId)).([]*model.ChannelMemberHistoryResult)
|
||||
assert.Len(t, histories, initialNumTownSquareUsers+1)
|
||||
|
||||
found := false
|
||||
@@ -142,14 +142,14 @@ func TestJoinDefaultChannelsOffTopic(t *testing.T) {
|
||||
|
||||
// figure out the initial number of users in off-topic
|
||||
offTopicChannelId := store.Must(th.App.Srv.Store.Channel().GetByName(th.BasicTeam.Id, "off-topic", true)).(*model.Channel).Id
|
||||
initialNumTownSquareUsers := len(store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, offTopicChannelId)).([]*model.ChannelMemberHistory))
|
||||
initialNumTownSquareUsers := len(store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, offTopicChannelId)).([]*model.ChannelMemberHistoryResult))
|
||||
|
||||
// create a new user that joins the default channels
|
||||
user := th.CreateUser()
|
||||
th.App.JoinDefaultChannels(th.BasicTeam.Id, user, model.CHANNEL_USER_ROLE_ID, "")
|
||||
|
||||
// there should be a ChannelMemberHistory record for the user
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, offTopicChannelId)).([]*model.ChannelMemberHistory)
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, offTopicChannelId)).([]*model.ChannelMemberHistoryResult)
|
||||
assert.Len(t, histories, initialNumTownSquareUsers+1)
|
||||
|
||||
found := false
|
||||
@@ -170,7 +170,7 @@ func TestCreateChannelPublic(t *testing.T) {
|
||||
publicChannel := th.createChannel(th.BasicTeam, model.CHANNEL_OPEN)
|
||||
|
||||
// there should be a ChannelMemberHistory record for the user
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, publicChannel.Id)).([]*model.ChannelMemberHistory)
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, publicChannel.Id)).([]*model.ChannelMemberHistoryResult)
|
||||
assert.Len(t, histories, 1)
|
||||
assert.Equal(t, th.BasicUser.Id, histories[0].UserId)
|
||||
assert.Equal(t, publicChannel.Id, histories[0].ChannelId)
|
||||
@@ -184,7 +184,7 @@ func TestCreateChannelPrivate(t *testing.T) {
|
||||
privateChannel := th.createChannel(th.BasicTeam, model.CHANNEL_PRIVATE)
|
||||
|
||||
// there should be a ChannelMemberHistory record for the user
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, privateChannel.Id)).([]*model.ChannelMemberHistory)
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, privateChannel.Id)).([]*model.ChannelMemberHistoryResult)
|
||||
assert.Len(t, histories, 1)
|
||||
assert.Equal(t, th.BasicUser.Id, histories[0].UserId)
|
||||
assert.Equal(t, privateChannel.Id, histories[0].ChannelId)
|
||||
@@ -221,7 +221,7 @@ func TestCreateGroupChannel(t *testing.T) {
|
||||
t.Fatal("Failed to create group channel. Error: " + err.Message)
|
||||
} else {
|
||||
// there should be a ChannelMemberHistory record for each user
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id)).([]*model.ChannelMemberHistory)
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id)).([]*model.ChannelMemberHistoryResult)
|
||||
assert.Len(t, histories, 3)
|
||||
|
||||
channelMemberHistoryUserIds := make([]string, 0)
|
||||
@@ -253,7 +253,7 @@ func TestAddUserToChannel(t *testing.T) {
|
||||
}
|
||||
|
||||
// there should be a ChannelMemberHistory record for the user
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id)).([]*model.ChannelMemberHistory)
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, channel.Id)).([]*model.ChannelMemberHistoryResult)
|
||||
assert.Len(t, histories, 2)
|
||||
channelMemberHistoryUserIds := make([]string, 0)
|
||||
for _, history := range histories {
|
||||
@@ -269,7 +269,7 @@ func TestRemoveUserFromChannel(t *testing.T) {
|
||||
|
||||
// a user creates a channel
|
||||
publicChannel := th.createChannel(th.BasicTeam, model.CHANNEL_OPEN)
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, publicChannel.Id)).([]*model.ChannelMemberHistory)
|
||||
histories := store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, publicChannel.Id)).([]*model.ChannelMemberHistoryResult)
|
||||
assert.Len(t, histories, 1)
|
||||
assert.Equal(t, th.BasicUser.Id, histories[0].UserId)
|
||||
assert.Equal(t, publicChannel.Id, histories[0].ChannelId)
|
||||
@@ -279,7 +279,7 @@ func TestRemoveUserFromChannel(t *testing.T) {
|
||||
if err := th.App.LeaveChannel(publicChannel.Id, th.BasicUser.Id); err != nil {
|
||||
t.Fatal("Failed to remove user from channel. Error: " + err.Message)
|
||||
}
|
||||
histories = store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, publicChannel.Id)).([]*model.ChannelMemberHistory)
|
||||
histories = store.Must(th.App.Srv.Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, publicChannel.Id)).([]*model.ChannelMemberHistoryResult)
|
||||
assert.Len(t, histories, 1)
|
||||
assert.Equal(t, th.BasicUser.Id, histories[0].UserId)
|
||||
assert.Equal(t, publicChannel.Id, histories[0].ChannelId)
|
||||
|
||||
Reference in New Issue
Block a user