From 5fbec91c35d7ea5d9b920b26a01fc21da55bb08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Wed, 8 Aug 2018 12:10:05 +0200 Subject: MM-9747: Small fixes for attachments import (#9225) * MM-9747: Small fixes for attachments import * Adding unit test RootId check in replies --- app/import_functions_test.go | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'app/import_functions_test.go') diff --git a/app/import_functions_test.go b/app/import_functions_test.go index e0859af45..fd8ae462e 100644 --- a/app/import_functions_test.go +++ b/app/import_functions_test.go @@ -1700,6 +1700,60 @@ func TestImportImportPost(t *testing.T) { } } } + + // Update post with replies. + data = &PostImportData{ + Team: &teamName, + Channel: &channelName, + User: &user2.Username, + Message: ptrStr("Message with reply"), + CreateAt: &replyPostTime, + Replies: &[]ReplyImportData{{ + User: &username, + Message: ptrStr("Message reply"), + CreateAt: &replyTime, + }}, + } + if err := th.App.ImportPost(data, false); err != nil { + t.Fatalf("Expected success.") + } + AssertAllPostsCount(t, th.App, initialPostCount, 8, team.Id) + + // Create new post with replies based on the previous one. + data = &PostImportData{ + Team: &teamName, + Channel: &channelName, + User: &user2.Username, + Message: ptrStr("Message with reply 2"), + CreateAt: &replyPostTime, + Replies: &[]ReplyImportData{{ + User: &username, + Message: ptrStr("Message reply"), + CreateAt: &replyTime, + }}, + } + if err := th.App.ImportPost(data, false); err != nil { + t.Fatalf("Expected success.") + } + AssertAllPostsCount(t, th.App, initialPostCount, 10, team.Id) + + // Create new reply for existing post with replies. + data = &PostImportData{ + Team: &teamName, + Channel: &channelName, + User: &user2.Username, + Message: ptrStr("Message with reply"), + CreateAt: &replyPostTime, + Replies: &[]ReplyImportData{{ + User: &username, + Message: ptrStr("Message reply 2"), + CreateAt: &replyTime, + }}, + } + if err := th.App.ImportPost(data, false); err != nil { + t.Fatalf("Expected success.") + } + AssertAllPostsCount(t, th.App, initialPostCount, 11, team.Id) } func TestImportImportDirectChannel(t *testing.T) { -- cgit v1.2.3-1-g7c22