diff options
Diffstat (limited to 'store/storetest')
-rw-r--r-- | store/storetest/channel_store.go | 34 | ||||
-rw-r--r-- | store/storetest/compliance_store.go | 8 | ||||
-rw-r--r-- | store/storetest/team_store.go | 59 | ||||
-rw-r--r-- | store/storetest/user_store.go | 96 |
4 files changed, 96 insertions, 101 deletions
diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index fe6700266..76ef21552 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -92,13 +92,13 @@ func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Nickname = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() u2.Nickname = model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1)) m1 := model.ChannelMember{} m1.ChannelId = o1.Id @@ -153,13 +153,13 @@ func testChannelStoreCreateDirectChannel(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Nickname = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() u2.Nickname = model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id})) + 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 { @@ -218,8 +218,8 @@ func testGetChannelUnread(t *testing.T, ss store.Store) { uid := model.NewId() m1 := &model.TeamMember{TeamId: teamId1, UserId: uid} m2 := &model.TeamMember{TeamId: teamId2, UserId: uid} - store.Must(ss.Team().SaveMember(m1)) - store.Must(ss.Team().SaveMember(m2)) + store.Must(ss.Team().SaveMember(m1, -1)) + store.Must(ss.Team().SaveMember(m2, -1)) notifyPropsModel := model.GetDefaultChannelNotifyProps() // Setup Channel 1 @@ -307,13 +307,13 @@ func testChannelStoreGet(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Nickname = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) u2 := model.User{} u2.Email = model.NewId() u2.Nickname = model.NewId() store.Must(ss.User().Save(&u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1)) o2 := model.Channel{} o2.TeamId = model.NewId() @@ -652,13 +652,13 @@ func testChannelMemberStore(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Nickname = model.NewId() store.Must(ss.User().Save(&u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) u2 := model.User{} u2.Email = model.NewId() u2.Nickname = model.NewId() store.Must(ss.User().Save(&u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1)) o1 := model.ChannelMember{} o1.ChannelId = c1.Id @@ -747,13 +747,13 @@ func testChannelDeleteMemberStore(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Nickname = model.NewId() store.Must(ss.User().Save(&u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) u2 := model.User{} u2.Email = model.NewId() u2.Nickname = model.NewId() store.Must(ss.User().Save(&u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1)) o1 := model.ChannelMember{} o1.ChannelId = c1.Id @@ -1494,7 +1494,7 @@ func testGetMemberCount(t *testing.T, ss store.Store) { DeleteAt: 0, } store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) m1 := model.ChannelMember{ ChannelId: c1.Id, @@ -1514,7 +1514,7 @@ func testGetMemberCount(t *testing.T, ss store.Store) { DeleteAt: 0, } store.Must(ss.User().Save(&u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) m2 := model.ChannelMember{ ChannelId: c1.Id, @@ -1535,7 +1535,7 @@ func testGetMemberCount(t *testing.T, ss store.Store) { DeleteAt: 0, } store.Must(ss.User().Save(&u3)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u3.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u3.Id}, -1)) m3 := model.ChannelMember{ ChannelId: c2.Id, @@ -1556,7 +1556,7 @@ func testGetMemberCount(t *testing.T, ss store.Store) { DeleteAt: 10000, } store.Must(ss.User().Save(u4)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u4.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u4.Id}, -1)) m4 := model.ChannelMember{ ChannelId: c1.Id, @@ -1596,7 +1596,7 @@ func testUpdateExtrasByUser(t *testing.T, ss store.Store) { DeleteAt: 0, } store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) m1 := model.ChannelMember{ ChannelId: c1.Id, diff --git a/store/storetest/compliance_store.go b/store/storetest/compliance_store.go index 0ca33df0d..514910f6f 100644 --- a/store/storetest/compliance_store.go +++ b/store/storetest/compliance_store.go @@ -81,13 +81,13 @@ func testComplianceExport(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Username = model.NewId() u1 = store.Must(ss.User().Save(u1)).(*model.User) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() u2.Username = model.NewId() u2 = store.Must(ss.User().Save(u2)).(*model.User) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u2.Id}, -1)) c1 := &model.Channel{} c1.TeamId = t1.Id @@ -243,13 +243,13 @@ func testComplianceExportDirectMessages(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Username = model.NewId() u1 = store.Must(ss.User().Save(u1)).(*model.User) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() u2.Username = model.NewId() u2 = store.Must(ss.User().Save(u2)).(*model.User) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u2.Id}, -1)) c1 := &model.Channel{} c1.TeamId = t1.Id diff --git a/store/storetest/team_store.go b/store/storetest/team_store.go index 9a3b7c490..a32de9dba 100644 --- a/store/storetest/team_store.go +++ b/store/storetest/team_store.go @@ -9,7 +9,6 @@ import ( "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/store" - "github.com/mattermost/mattermost-server/utils" ) func TestTeamStore(t *testing.T, ss store.Store) { @@ -367,7 +366,7 @@ func testTeamStoreByUserId(t *testing.T, ss store.Store) { o1 = store.Must(ss.Team().Save(o1)).(*model.Team) m1 := &model.TeamMember{TeamId: o1.Id, UserId: model.NewId()} - store.Must(ss.Team().SaveMember(m1)) + store.Must(ss.Team().SaveMember(m1, -1)) if r1 := <-ss.Team().GetTeamsByUserId(m1.UserId); r1.Err != nil { t.Fatal(r1.Err) @@ -569,12 +568,12 @@ func testTeamMembers(t *testing.T, ss store.Store) { m2 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()} m3 := &model.TeamMember{TeamId: teamId2, UserId: model.NewId()} - if r1 := <-ss.Team().SaveMember(m1); r1.Err != nil { + if r1 := <-ss.Team().SaveMember(m1, -1); r1.Err != nil { t.Fatal(r1.Err) } - store.Must(ss.Team().SaveMember(m2)) - store.Must(ss.Team().SaveMember(m3)) + store.Must(ss.Team().SaveMember(m2, -1)) + store.Must(ss.Team().SaveMember(m3, -1)) if r1 := <-ss.Team().GetMembers(teamId1, 0, 100); r1.Err != nil { t.Fatal(r1.Err) @@ -635,7 +634,7 @@ func testTeamMembers(t *testing.T, ss store.Store) { } } - store.Must(ss.Team().SaveMember(m1)) + store.Must(ss.Team().SaveMember(m1, -1)) if r1 := <-ss.Team().RemoveAllMembersByTeam(teamId1); r1.Err != nil { t.Fatal(r1.Err) @@ -654,8 +653,8 @@ func testTeamMembers(t *testing.T, ss store.Store) { uid := model.NewId() m4 := &model.TeamMember{TeamId: teamId1, UserId: uid} m5 := &model.TeamMember{TeamId: teamId2, UserId: uid} - store.Must(ss.Team().SaveMember(m4)) - store.Must(ss.Team().SaveMember(m5)) + store.Must(ss.Team().SaveMember(m4, -1)) + store.Must(ss.Team().SaveMember(m5, -1)) if r1 := <-ss.Team().GetTeamsForUser(uid); r1.Err != nil { t.Fatal(r1.Err) @@ -683,11 +682,7 @@ func testTeamMembers(t *testing.T, ss store.Store) { } func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) { - MaxUsersPerTeam := *utils.Cfg.TeamSettings.MaxUsersPerTeam - defer func() { - *utils.Cfg.TeamSettings.MaxUsersPerTeam = MaxUsersPerTeam - }() - *utils.Cfg.TeamSettings.MaxUsersPerTeam = 5 + maxUsersPerTeam := 5 team := store.Must(ss.Team().Save(&model.Team{ DisplayName: "DisplayName", @@ -698,9 +693,9 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) { <-ss.Team().PermanentDelete(team.Id) }() - userIds := make([]string, *utils.Cfg.TeamSettings.MaxUsersPerTeam) + userIds := make([]string, maxUsersPerTeam) - for i := 0; i < *utils.Cfg.TeamSettings.MaxUsersPerTeam; i++ { + for i := 0; i < maxUsersPerTeam; i++ { userIds[i] = store.Must(ss.User().Save(&model.User{ Username: model.NewId(), Email: model.NewId(), @@ -713,7 +708,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) { store.Must(ss.Team().SaveMember(&model.TeamMember{ TeamId: team.Id, UserId: userIds[i], - })) + }, maxUsersPerTeam)) defer func(userId string) { <-ss.Team().RemoveMember(team.Id, userId) @@ -722,7 +717,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) { if result := <-ss.Team().GetTotalMemberCount(team.Id); result.Err != nil { t.Fatal(result.Err) - } else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam { + } else if count := result.Data.(int64); int(count) != maxUsersPerTeam { t.Fatalf("should start with 5 team members, had %v instead", count) } @@ -737,13 +732,13 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) { if result := <-ss.Team().SaveMember(&model.TeamMember{ TeamId: team.Id, UserId: newUserId, - }); result.Err == nil { + }, maxUsersPerTeam); result.Err == nil { t.Fatal("shouldn't be able to save member when at maximum members per team") } if result := <-ss.Team().GetTotalMemberCount(team.Id); result.Err != nil { t.Fatal(result.Err) - } else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam { + } else if count := result.Data.(int64); int(count) != maxUsersPerTeam { t.Fatalf("should still have 5 team members, had %v instead", count) } @@ -756,11 +751,11 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) { if result := <-ss.Team().GetTotalMemberCount(team.Id); result.Err != nil { t.Fatal(result.Err) - } else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam-1 { + } else if count := result.Data.(int64); int(count) != maxUsersPerTeam-1 { t.Fatalf("should now only have 4 team members, had %v instead", count) } - if result := <-ss.Team().SaveMember(&model.TeamMember{TeamId: team.Id, UserId: newUserId}); result.Err != nil { + if result := <-ss.Team().SaveMember(&model.TeamMember{TeamId: team.Id, UserId: newUserId}, maxUsersPerTeam); result.Err != nil { t.Fatal("should've been able to save new member after deleting one", result.Err) } else { defer func(userId string) { @@ -770,7 +765,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) { if result := <-ss.Team().GetTotalMemberCount(team.Id); result.Err != nil { t.Fatal(result.Err) - } else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam { + } else if count := result.Data.(int64); int(count) != maxUsersPerTeam { t.Fatalf("should have 5 team members again, had %v instead", count) } @@ -783,7 +778,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) { Username: model.NewId(), Email: model.NewId(), })).(*model.User).Id - if result := <-ss.Team().SaveMember(&model.TeamMember{TeamId: team.Id, UserId: newUserId2}); result.Err != nil { + if result := <-ss.Team().SaveMember(&model.TeamMember{TeamId: team.Id, UserId: newUserId2}, maxUsersPerTeam); result.Err != nil { t.Fatal("should've been able to save new member after deleting one", result.Err) } else { defer func(userId string) { @@ -796,7 +791,7 @@ func testGetTeamMember(t *testing.T, ss store.Store) { teamId1 := model.NewId() m1 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()} - store.Must(ss.Team().SaveMember(m1)) + store.Must(ss.Team().SaveMember(m1, -1)) if r := <-ss.Team().GetMember(m1.TeamId, m1.UserId); r.Err != nil { t.Fatal(r.Err) @@ -825,7 +820,7 @@ func testGetTeamMembersByIds(t *testing.T, ss store.Store) { teamId1 := model.NewId() m1 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()} - store.Must(ss.Team().SaveMember(m1)) + store.Must(ss.Team().SaveMember(m1, -1)) if r := <-ss.Team().GetMembersByIds(m1.TeamId, []string{m1.UserId}); r.Err != nil { t.Fatal(r.Err) @@ -842,7 +837,7 @@ func testGetTeamMembersByIds(t *testing.T, ss store.Store) { } m2 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()} - store.Must(ss.Team().SaveMember(m2)) + store.Must(ss.Team().SaveMember(m2, -1)) if r := <-ss.Team().GetMembersByIds(m1.TeamId, []string{m1.UserId, m2.UserId, model.NewId()}); r.Err != nil { t.Fatal(r.Err) @@ -871,10 +866,10 @@ func testTeamStoreMemberCount(t *testing.T, ss store.Store) { teamId1 := model.NewId() m1 := &model.TeamMember{TeamId: teamId1, UserId: u1.Id} - store.Must(ss.Team().SaveMember(m1)) + store.Must(ss.Team().SaveMember(m1, -1)) m2 := &model.TeamMember{TeamId: teamId1, UserId: u2.Id} - store.Must(ss.Team().SaveMember(m2)) + store.Must(ss.Team().SaveMember(m2, -1)) if result := <-ss.Team().GetTotalMemberCount(teamId1); result.Err != nil { t.Fatal(result.Err) @@ -893,7 +888,7 @@ func testTeamStoreMemberCount(t *testing.T, ss store.Store) { } m3 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()} - store.Must(ss.Team().SaveMember(m3)) + store.Must(ss.Team().SaveMember(m3, -1)) if result := <-ss.Team().GetTotalMemberCount(teamId1); result.Err != nil { t.Fatal(result.Err) @@ -919,8 +914,8 @@ func testGetChannelUnreadsForAllTeams(t *testing.T, ss store.Store) { uid := model.NewId() m1 := &model.TeamMember{TeamId: teamId1, UserId: uid} m2 := &model.TeamMember{TeamId: teamId2, UserId: uid} - store.Must(ss.Team().SaveMember(m1)) - store.Must(ss.Team().SaveMember(m2)) + store.Must(ss.Team().SaveMember(m1, -1)) + store.Must(ss.Team().SaveMember(m2, -1)) c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100} store.Must(ss.Channel().Save(c1, -1)) @@ -983,7 +978,7 @@ func testGetChannelUnreadsForTeam(t *testing.T, ss store.Store) { uid := model.NewId() m1 := &model.TeamMember{TeamId: teamId1, UserId: uid} - store.Must(ss.Team().SaveMember(m1)) + store.Must(ss.Team().SaveMember(m1, -1)) c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100} store.Must(ss.Channel().Save(c1, -1)) diff --git a/store/storetest/user_store.go b/store/storetest/user_store.go index 3c2297e95..cf2837456 100644 --- a/store/storetest/user_store.go +++ b/store/storetest/user_store.go @@ -50,6 +50,7 @@ func TestUserStore(t *testing.T, ss store.Store) { func testUserStoreSave(t *testing.T, ss store.Store) { teamId := model.NewId() + maxUsersPerTeam := 50 u1 := model.User{} u1.Email = model.NewId() @@ -59,7 +60,7 @@ func testUserStoreSave(t *testing.T, ss store.Store) { t.Fatal("couldn't save user", err) } - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, maxUsersPerTeam)) if err := (<-ss.User().Save(&u1)).Err; err == nil { t.Fatal("shouldn't be able to update user from save") @@ -89,7 +90,7 @@ func testUserStoreSave(t *testing.T, ss store.Store) { t.Fatal("couldn't save item", err) } - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, maxUsersPerTeam)) } u1.Id = "" @@ -99,23 +100,22 @@ func testUserStoreSave(t *testing.T, ss store.Store) { t.Fatal("couldn't save item", err) } - if err := (<-ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})).Err; err == nil { + if err := (<-ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, maxUsersPerTeam)).Err; err == nil { t.Fatal("should be the limit") } - } func testUserStoreUpdate(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() u2.AuthService = "ldap" store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1)) time.Sleep(100 * time.Millisecond) @@ -143,7 +143,7 @@ func testUserStoreUpdate(t *testing.T, ss store.Store) { oldEmail := u3.Email u3.AuthService = "gitlab" store.Must(ss.User().Save(u3)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u3.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u3.Id}, -1)) u3.Email = model.NewId() if result := <-ss.User().Update(u3, false); result.Err != nil { @@ -173,7 +173,7 @@ func testUserStoreUpdateUpdateAt(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) time.Sleep(10 * time.Millisecond) @@ -195,7 +195,7 @@ func testUserStoreUpdateFailedPasswordAttempts(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) if err := (<-ss.User().UpdateFailedPasswordAttempts(u1.Id, 3)).Err; err != nil { t.Fatal(err) @@ -215,7 +215,7 @@ func testUserStoreGet(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) if r1 := <-ss.User().Get(u1.Id); r1.Err != nil { t.Fatal(r1.Err) @@ -234,7 +234,7 @@ func testUserCount(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) if result := <-ss.User().GetTotalUsersCount(); result.Err != nil { t.Fatal(result.Err) @@ -329,12 +329,12 @@ func testUserStoreGetProfiles(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) if r1 := <-ss.User().GetProfiles(teamId, 0, 100); r1.Err != nil { t.Fatal(r1.Err) @@ -374,7 +374,7 @@ func testUserStoreGetProfiles(t *testing.T, ss store.Store) { u3 := &model.User{} u3.Email = model.NewId() store.Must(ss.User().Save(u3)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u3.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u3.Id}, -1)) if r2 := <-ss.User().GetEtagForProfiles(teamId); r2.Err != nil { t.Fatal(r2.Err) @@ -391,12 +391,12 @@ func testUserStoreGetProfilesInChannel(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) c1 := model.Channel{} c1.TeamId = teamId @@ -470,7 +470,7 @@ func testUserStoreGetProfilesWithoutTeam(t *testing.T, ss store.Store) { u1.Username = "a000000000" + model.NewId() u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) defer ss.User().PermanentDelete(u1.Id) u2 := &model.User{} @@ -508,12 +508,12 @@ func testUserStoreGetAllProfilesInChannel(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) c1 := model.Channel{} c1.TeamId = teamId @@ -596,12 +596,12 @@ func testUserStoreGetProfilesNotInChannel(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) c1 := model.Channel{} c1.TeamId = teamId @@ -689,12 +689,12 @@ func testUserStoreGetProfilesByIds(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) if r1 := <-ss.User().GetProfileByIds([]string{u1.Id}, false); r1.Err != nil { t.Fatal(r1.Err) @@ -832,13 +832,13 @@ func testUserStoreGetProfilesByUsernames(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Username = "username1" + model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() u2.Username = "username2" + model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) if r1 := <-ss.User().GetProfilesByUsernames([]string{u1.Username, u2.Username}, teamId); r1.Err != nil { t.Fatal(r1.Err) @@ -876,7 +876,7 @@ func testUserStoreGetProfilesByUsernames(t *testing.T, ss store.Store) { u3.Email = model.NewId() u3.Username = "username3" + model.NewId() store.Must(ss.User().Save(u3)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: team2Id, UserId: u3.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: team2Id, UserId: u3.Id}, -1)) if r1 := <-ss.User().GetProfilesByUsernames([]string{u1.Username, u3.Username}, ""); r1.Err != nil { t.Fatal(r1.Err) @@ -916,12 +916,12 @@ func testUserStoreGetSystemAdminProfiles(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Roles = model.ROLE_SYSTEM_USER.Id + " " + model.ROLE_SYSTEM_ADMIN.Id store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) if r1 := <-ss.User().GetSystemAdminProfiles(); r1.Err != nil { t.Fatal(r1.Err) @@ -939,7 +939,7 @@ func testUserStoreGetByEmail(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamid, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamid, UserId: u1.Id}, -1)) if err := (<-ss.User().GetByEmail(u1.Email)).Err; err != nil { t.Fatal(err) @@ -960,7 +960,7 @@ func testUserStoreGetByAuthData(t *testing.T, ss store.Store) { u1.AuthData = &auth u1.AuthService = "service" store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) if err := (<-ss.User().GetByAuth(u1.AuthData, u1.AuthService)).Err; err != nil { t.Fatal(err) @@ -979,7 +979,7 @@ func testUserStoreGetByUsername(t *testing.T, ss store.Store) { u1.Email = model.NewId() u1.Username = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) if err := (<-ss.User().GetByUsername(u1.Username)).Err; err != nil { t.Fatal(err) @@ -1077,7 +1077,7 @@ func testUserStoreUpdatePassword(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) hashedPassword := model.HashPassword("newpwd") @@ -1099,7 +1099,7 @@ func testUserStoreDelete(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1)) if err := (<-ss.User().PermanentDelete(u1.Id)).Err; err != nil { t.Fatal(err) @@ -1112,7 +1112,7 @@ func testUserStoreUpdateAuthData(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) service := "someservice" authData := model.NewId() @@ -1156,13 +1156,13 @@ func testUserUnreadCount(t *testing.T, ss store.Store) { u1.Username = "user1" + model.NewId() u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) u2 := &model.User{} u2.Email = model.NewId() u2.Username = "user2" + model.NewId() store.Must(ss.User().Save(u2)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) if err := (<-ss.Channel().Save(&c1, -1)).Err; err != nil { t.Fatal("couldn't save item", err) @@ -1272,7 +1272,7 @@ func testUserStoreGetRecentlyActiveUsersForTeam(t *testing.T, ss store.Store) { store.Must(ss.User().Save(u1)) store.Must(ss.Status().SaveOrUpdate(&model.Status{UserId: u1.Id, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""})) tid := model.NewId() - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u1.Id}, -1)) if r1 := <-ss.User().GetRecentlyActiveUsersForTeam(tid, 0, 100); r1.Err != nil { t.Fatal(r1.Err) @@ -1285,7 +1285,7 @@ func testUserStoreGetNewUsersForTeam(t *testing.T, ss store.Store) { store.Must(ss.User().Save(u1)) store.Must(ss.Status().SaveOrUpdate(&model.Status{UserId: u1.Id, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""})) tid := model.NewId() - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u1.Id}, -1)) if r1 := <-ss.User().GetNewUsersForTeam(tid, 0, 100); r1.Err != nil { t.Fatal(r1.Err) @@ -1329,11 +1329,11 @@ func testUserStoreSearch(t *testing.T, ss store.Store) { store.Must(ss.User().Save(u6)) tid := model.NewId() - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u1.Id})) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u2.Id})) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u3.Id})) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u5.Id})) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u6.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u1.Id}, -1)) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u2.Id}, -1)) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u3.Id}, -1)) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u5.Id}, -1)) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u6.Id}, -1)) searchOptions := map[string]bool{} searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY] = true @@ -1781,7 +1781,7 @@ func testUserStoreSearch(t *testing.T, ss store.Store) { } // Check SearchNotInTeam finds previously deleted team members. - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u4.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u4.Id}, -1)) if r1 := <-ss.User().SearchNotInTeam(tid, "simo", searchOptions); r1.Err != nil { t.Fatal(r1.Err) @@ -1840,7 +1840,7 @@ func testUserStoreSearchWithoutTeam(t *testing.T, ss store.Store) { store.Must(ss.User().Save(u3)) tid := model.NewId() - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u3.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u3.Id}, -1)) searchOptions := map[string]bool{} searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY] = true @@ -1947,7 +1947,7 @@ func testUserStoreGetProfilesNotInTeam(t *testing.T, ss store.Store) { u1 := &model.User{} u1.Email = model.NewId() store.Must(ss.User().Save(u1)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)) store.Must(ss.User().UpdateUpdateAt(u1.Id)) u2 := &model.User{} @@ -1989,7 +1989,7 @@ func testUserStoreGetProfilesNotInTeam(t *testing.T, ss store.Store) { } time.Sleep(time.Millisecond * 10) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1)) store.Must(ss.User().UpdateUpdateAt(u2.Id)) if er2 := <-ss.User().GetEtagForProfilesNotInTeam(teamId); er2.Err != nil { @@ -2059,7 +2059,7 @@ func testUserStoreGetProfilesNotInTeam(t *testing.T, ss store.Store) { u3 := &model.User{} u3.Email = model.NewId() store.Must(ss.User().Save(u3)) - store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u3.Id})) + store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u3.Id}, -1)) store.Must(ss.User().UpdateUpdateAt(u3.Id)) if er4 := <-ss.User().GetEtagForProfilesNotInTeam(teamId); er4.Err != nil { |