summaryrefslogtreecommitdiffstats
path: root/store/sql_post_store_test.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-11-16 17:12:49 -0800
committer=Corey Hulen <corey@hulen.com>2015-11-16 17:12:49 -0800
commit6b2eabf6108e078bed8143e91c605dec5ccfafa6 (patch)
tree0d60cd7f3dac8092bd0bd4e39e2890a6170055c3 /store/sql_post_store_test.go
parent03c6dcbd865e2af2db5db150189504bfa493ae2e (diff)
downloadchat-6b2eabf6108e078bed8143e91c605dec5ccfafa6.tar.gz
chat-6b2eabf6108e078bed8143e91c605dec5ccfafa6.tar.bz2
chat-6b2eabf6108e078bed8143e91c605dec5ccfafa6.zip
Adding perm delete to cmd line
Diffstat (limited to 'store/sql_post_store_test.go')
-rw-r--r--store/sql_post_store_test.go70
1 files changed, 70 insertions, 0 deletions
diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go
index fe7195a54..d9b087ea7 100644
--- a/store/sql_post_store_test.go
+++ b/store/sql_post_store_test.go
@@ -247,6 +247,76 @@ func TestPostStoreDelete2Level(t *testing.T) {
}
}
+func TestPostStorePermDelete1Level(t *testing.T) {
+ Setup()
+
+ o1 := &model.Post{}
+ o1.ChannelId = model.NewId()
+ o1.UserId = model.NewId()
+ o1.Message = "a" + model.NewId() + "b"
+ o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+
+ o2 := &model.Post{}
+ o2.ChannelId = o1.ChannelId
+ o2.UserId = model.NewId()
+ o2.Message = "a" + model.NewId() + "b"
+ o2.ParentId = o1.Id
+ o2.RootId = o1.Id
+ o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+
+ if r2 := <-store.Post().PermanentDeleteByUser(o2.UserId); r2.Err != nil {
+ t.Fatal(r2.Err)
+ }
+
+ if r3 := (<-store.Post().Get(o1.Id)); r3.Err != nil {
+ t.Fatal("Deleted id shouldn't have failed")
+ }
+
+ if r4 := (<-store.Post().Get(o2.Id)); r4.Err == nil {
+ t.Fatal("Deleted id should have failed")
+ }
+}
+
+func TestPostStorePermDelete1Level2(t *testing.T) {
+ Setup()
+
+ o1 := &model.Post{}
+ o1.ChannelId = model.NewId()
+ o1.UserId = model.NewId()
+ o1.Message = "a" + model.NewId() + "b"
+ o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+
+ o2 := &model.Post{}
+ o2.ChannelId = o1.ChannelId
+ o2.UserId = model.NewId()
+ o2.Message = "a" + model.NewId() + "b"
+ o2.ParentId = o1.Id
+ o2.RootId = o1.Id
+ o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+
+ o3 := &model.Post{}
+ o3.ChannelId = model.NewId()
+ o3.UserId = model.NewId()
+ o3.Message = "a" + model.NewId() + "b"
+ o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
+
+ if r2 := <-store.Post().PermanentDeleteByUser(o1.UserId); r2.Err != nil {
+ t.Fatal(r2.Err)
+ }
+
+ if r3 := (<-store.Post().Get(o1.Id)); r3.Err == nil {
+ t.Fatal("Deleted id should have failed")
+ }
+
+ if r4 := (<-store.Post().Get(o2.Id)); r4.Err == nil {
+ t.Fatal("Deleted id should have failed")
+ }
+
+ if r5 := (<-store.Post().Get(o3.Id)); r5.Err != nil {
+ t.Fatal("Deleted id shouldn't have failed")
+ }
+}
+
func TestPostStoreGetWithChildren(t *testing.T) {
Setup()