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_file_info_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_file_info_store_test.go')
-rw-r--r-- | store/sql_file_info_store_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/store/sql_file_info_store_test.go b/store/sql_file_info_store_test.go index b62083136..c08bed7d4 100644 --- a/store/sql_file_info_store_test.go +++ b/store/sql_file_info_store_test.go @@ -256,3 +256,44 @@ func TestFileInfoPermanentDelete(t *testing.T) { t.Fatal(result.Err) } } + +func TestFileInfoPermanentDeleteBatch(t *testing.T) { + Setup() + + postId := model.NewId() + + Must(store.FileInfo().Save(&model.FileInfo{ + PostId: postId, + CreatorId: model.NewId(), + Path: "file.txt", + CreateAt: 1000, + })) + + Must(store.FileInfo().Save(&model.FileInfo{ + PostId: postId, + CreatorId: model.NewId(), + Path: "file.txt", + CreateAt: 1200, + })) + + Must(store.FileInfo().Save(&model.FileInfo{ + PostId: postId, + CreatorId: model.NewId(), + Path: "file.txt", + CreateAt: 2000, + })) + + if result := <-store.FileInfo().GetForPost(postId, true, false); result.Err != nil { + t.Fatal(result.Err) + } else if len(result.Data.([]*model.FileInfo)) != 3 { + t.Fatal("Expected 3 fileInfos") + } + + Must(store.FileInfo().PermanentDeleteBatch(1500, 1000)) + + if result := <-store.FileInfo().GetForPost(postId, true, false); result.Err != nil { + t.Fatal(result.Err) + } else if len(result.Data.([]*model.FileInfo)) != 1 { + t.Fatal("Expected 3 fileInfos") + } +} |