diff options
author | George Goldberg <george@gberg.me> | 2017-09-15 17:35:55 +0100 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-09-15 09:35:55 -0700 |
commit | 8195c80aa12136838ff4491fac989e0b946382b1 (patch) | |
tree | da24729af5acbd3349c75923d346cfa7aa9ad95c /store/sql_post_store_test.go | |
parent | 2628022275ef64fde95545abe4634b4bd7177844 (diff) | |
download | chat-8195c80aa12136838ff4491fac989e0b946382b1.tar.gz chat-8195c80aa12136838ff4491fac989e0b946382b1.tar.bz2 chat-8195c80aa12136838ff4491fac989e0b946382b1.zip |
PLT-7639: Batch delete methods for data retention. (#7444)
Diffstat (limited to 'store/sql_post_store_test.go')
-rw-r--r-- | store/sql_post_store_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go index 79892b5f5..304fb9f8a 100644 --- a/store/sql_post_store_test.go +++ b/store/sql_post_store_test.go @@ -1661,3 +1661,42 @@ func TestPostStoreGetPostsBatchForIndexing(t *testing.T) { } } } + +func TestPostStorePermanentDeleteBatch(t *testing.T) { + Setup() + + o1 := &model.Post{} + o1.ChannelId = model.NewId() + o1.UserId = model.NewId() + o1.Message = "zz" + model.NewId() + "AAAAAAAAAAA" + o1.CreateAt = 1000 + o1 = (<-store.Post().Save(o1)).Data.(*model.Post) + + o2 := &model.Post{} + o2.ChannelId = model.NewId() + o2.UserId = model.NewId() + o2.Message = "zz" + model.NewId() + "AAAAAAAAAAA" + o2.CreateAt = 1000 + o2 = (<-store.Post().Save(o2)).Data.(*model.Post) + + o3 := &model.Post{} + o3.ChannelId = model.NewId() + o3.UserId = model.NewId() + o3.Message = "zz" + model.NewId() + "AAAAAAAAAAA" + o3.CreateAt = 100000 + o3 = (<-store.Post().Save(o3)).Data.(*model.Post) + + Must(store.Post().PermanentDeleteBatch(2000, 1000)) + + if p := <-store.Post().Get(o1.Id); p.Err == nil { + t.Fatalf("Should have not found post 1 after purge") + } + + if p := <-store.Post().Get(o2.Id); p.Err == nil { + t.Fatalf("Should have not found post 2 after purge") + } + + if p := <-store.Post().Get(o3.Id); p.Err != nil { + t.Fatalf("Should have found post 3 after purge") + } +} |