diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-11-18 12:48:45 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-11-18 12:48:45 -0500 |
commit | e408d615c02ae3c863df3c7dc13d1b813c22fd28 (patch) | |
tree | a1c607b7721831c71aadbf89f018ed7b11a0e426 /store/sql_post_store_test.go | |
parent | 9660adb00775aba822d2d684d215c55679a456c6 (diff) | |
parent | c115191d6b5abdefda856c063e3f9048dc82f830 (diff) | |
download | chat-e408d615c02ae3c863df3c7dc13d1b813c22fd28.tar.gz chat-e408d615c02ae3c863df3c7dc13d1b813c22fd28.tar.bz2 chat-e408d615c02ae3c863df3c7dc13d1b813c22fd28.zip |
Merge pull request #1448 from mattermost/PLT-975
PLT-975 adding delete to command line tool
Diffstat (limited to 'store/sql_post_store_test.go')
-rw-r--r-- | store/sql_post_store_test.go | 70 |
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() |