summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'store/sql_channel_store_test.go')
-rw-r--r--store/sql_channel_store_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index 8662fcbd3..695991bf7 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -379,6 +379,63 @@ func TestChannelMemberStore(t *testing.T) {
}
}
+func TestChannelDeleteMemberStore(t *testing.T) {
+ Setup()
+
+ c1 := model.Channel{}
+ c1.TeamId = model.NewId()
+ c1.DisplayName = "NameName"
+ c1.Name = "a" + model.NewId() + "b"
+ c1.Type = model.CHANNEL_OPEN
+ c1 = *Must(store.Channel().Save(&c1)).(*model.Channel)
+
+ c1t1 := (<-store.Channel().Get(c1.Id)).Data.(*model.Channel)
+ t1 := c1t1.ExtraUpdateAt
+
+ u1 := model.User{}
+ u1.TeamId = model.NewId()
+ u1.Email = model.NewId()
+ u1.Nickname = model.NewId()
+ Must(store.User().Save(&u1))
+
+ u2 := model.User{}
+ u2.TeamId = model.NewId()
+ u2.Email = model.NewId()
+ u2.Nickname = model.NewId()
+ Must(store.User().Save(&u2))
+
+ o1 := model.ChannelMember{}
+ o1.ChannelId = c1.Id
+ o1.UserId = u1.Id
+ o1.NotifyProps = model.GetDefaultChannelNotifyProps()
+ Must(store.Channel().SaveMember(&o1))
+
+ o2 := model.ChannelMember{}
+ o2.ChannelId = c1.Id
+ o2.UserId = u2.Id
+ o2.NotifyProps = model.GetDefaultChannelNotifyProps()
+ Must(store.Channel().SaveMember(&o2))
+
+ c1t2 := (<-store.Channel().Get(c1.Id)).Data.(*model.Channel)
+ t2 := c1t2.ExtraUpdateAt
+
+ if t2 <= t1 {
+ t.Fatal("Member update time incorrect")
+ }
+
+ count := (<-store.Channel().GetMemberCount(o1.ChannelId)).Data.(int64)
+ if count != 2 {
+ t.Fatal("should have saved 2 members")
+ }
+
+ Must(store.Channel().PermanentDeleteMembersByUser(o2.UserId))
+
+ count = (<-store.Channel().GetMemberCount(o1.ChannelId)).Data.(int64)
+ if count != 1 {
+ t.Fatal("should have removed 1 member")
+ }
+}
+
func TestChannelStorePermissionsTo(t *testing.T) {
Setup()