diff options
author | Martin Kraft <mkraft@users.noreply.github.com> | 2018-06-01 12:45:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-01 12:45:46 -0400 |
commit | 260d7a0f850a6f772b14b011022f1f65213a08a1 (patch) | |
tree | 1090ef2c0c1447be9e64baecd0d7336514922927 /store/storetest/post_store.go | |
parent | 5992a729c50989b7a39e42a0aaed42bc3914fb13 (diff) | |
download | chat-260d7a0f850a6f772b14b011022f1f65213a08a1.tar.gz chat-260d7a0f850a6f772b14b011022f1f65213a08a1.tar.bz2 chat-260d7a0f850a6f772b14b011022f1f65213a08a1.zip |
MM-10412: Adds deleteBy prop to posts. (#8896)
Diffstat (limited to 'store/storetest/post_store.go')
-rw-r--r-- | store/storetest/post_store.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/store/storetest/post_store.go b/store/storetest/post_store.go index 6ebb875bf..1159af37f 100644 --- a/store/storetest/post_store.go +++ b/store/storetest/post_store.go @@ -247,6 +247,7 @@ func testPostStoreDelete(t *testing.T, ss store.Store) { o1.ChannelId = model.NewId() o1.UserId = model.NewId() o1.Message = "zz" + model.NewId() + "b" + deleteByID := model.NewId() etag1 := (<-ss.Post().GetEtag(o1.ChannelId, false)).Data.(string) if strings.Index(etag1, model.CurrentVersion+".") != 0 { @@ -263,10 +264,17 @@ func testPostStoreDelete(t *testing.T, ss store.Store) { } } - if r2 := <-ss.Post().Delete(o1.Id, model.GetMillis()); r2.Err != nil { + if r2 := <-ss.Post().Delete(o1.Id, model.GetMillis(), deleteByID); r2.Err != nil { t.Fatal(r2.Err) } + r5 := <-ss.Post().GetPostsCreatedAt(o1.ChannelId, o1.CreateAt) + post := r5.Data.([]*model.Post)[0] + actual := post.Props[model.POST_PROPS_DELETE_BY] + if actual != deleteByID { + t.Errorf("Expected (*Post).Props[model.POST_PROPS_DELETE_BY] to be %v but got %v.", deleteByID, actual) + } + if r3 := (<-ss.Post().Get(o1.Id)); r3.Err == nil { t.Log(r3.Data) t.Fatal("Missing id should have failed") @@ -293,7 +301,7 @@ func testPostStoreDelete1Level(t *testing.T, ss store.Store) { o2.RootId = o1.Id o2 = (<-ss.Post().Save(o2)).Data.(*model.Post) - if r2 := <-ss.Post().Delete(o1.Id, model.GetMillis()); r2.Err != nil { + if r2 := <-ss.Post().Delete(o1.Id, model.GetMillis(), ""); r2.Err != nil { t.Fatal(r2.Err) } @@ -335,7 +343,7 @@ func testPostStoreDelete2Level(t *testing.T, ss store.Store) { o4.Message = "zz" + model.NewId() + "b" o4 = (<-ss.Post().Save(o4)).Data.(*model.Post) - if r2 := <-ss.Post().Delete(o1.Id, model.GetMillis()); r2.Err != nil { + if r2 := <-ss.Post().Delete(o1.Id, model.GetMillis(), ""); r2.Err != nil { t.Fatal(r2.Err) } @@ -468,7 +476,7 @@ func testPostStoreGetWithChildren(t *testing.T, ss store.Store) { } } - store.Must(ss.Post().Delete(o3.Id, model.GetMillis())) + store.Must(ss.Post().Delete(o3.Id, model.GetMillis(), "")) if r2 := <-ss.Post().Get(o1.Id); r2.Err != nil { t.Fatal(r2.Err) @@ -479,7 +487,7 @@ func testPostStoreGetWithChildren(t *testing.T, ss store.Store) { } } - store.Must(ss.Post().Delete(o2.Id, model.GetMillis())) + store.Must(ss.Post().Delete(o2.Id, model.GetMillis(), "")) if r3 := <-ss.Post().Get(o1.Id); r3.Err != nil { t.Fatal(r3.Err) @@ -1589,7 +1597,7 @@ func testPostStoreGetPostsByIds(t *testing.T, ss store.Store) { t.Fatalf("Expected 3 posts in results. Got %v", len(ro4)) } - store.Must(ss.Post().Delete(ro1.Id, model.GetMillis())) + store.Must(ss.Post().Delete(ro1.Id, model.GetMillis(), "")) if ro5 := store.Must(ss.Post().GetPostsByIds(postIds)).([]*model.Post); len(ro5) != 2 { t.Fatalf("Expected 2 posts in results. Got %v", len(ro5)) |