summaryrefslogtreecommitdiffstats
path: root/store/storetest
diff options
context:
space:
mode:
Diffstat (limited to 'store/storetest')
-rw-r--r--store/storetest/mocks/PostStore.go6
-rw-r--r--store/storetest/post_store.go20
2 files changed, 17 insertions, 9 deletions
diff --git a/store/storetest/mocks/PostStore.go b/store/storetest/mocks/PostStore.go
index 130bfafd7..8f56bc4b2 100644
--- a/store/storetest/mocks/PostStore.go
+++ b/store/storetest/mocks/PostStore.go
@@ -67,12 +67,12 @@ func (_m *PostStore) ClearCaches() {
}
// Delete provides a mock function with given fields: postId, time
-func (_m *PostStore) Delete(postId string, time int64) store.StoreChannel {
+func (_m *PostStore) Delete(postId string, time int64, deleteByID string) store.StoreChannel {
ret := _m.Called(postId, time)
var r0 store.StoreChannel
- if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
- r0 = rf(postId, time)
+ if rf, ok := ret.Get(0).(func(string, int64, string) store.StoreChannel); ok {
+ r0 = rf(postId, time, deleteByID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel)
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))