-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start fixing the combined flags -a and -p
- Loading branch information
Showing
3 changed files
with
67 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ func TestWriteFile(t *testing.T) { | |
ofMock.EXPECT().WriteAttachment("attachment1.jpeg").Return(true, nil), | ||
osMock.EXPECT().FileExist("attachment2.jpeg").Return(true, nil), | ||
osMock.EXPECT().HEIC2JPG("attachment2.jpeg").Return("attachment2.jpeg", nil), | ||
ofMock.EXPECT().WriteAttachment("attachment2.jpeg"), | ||
ofMock.EXPECT().WriteAttachment("attachment2.jpeg").Return(true, nil), | ||
ofMock.EXPECT().Name().Return("messages-export/friend/iMessage;-;[email protected];;;iMessage;-;[email protected]"), | ||
ofMock.EXPECT().ReferenceAttachment("att3transfer.png"), | ||
ofMock.EXPECT().Stage(), | ||
|
@@ -86,7 +86,7 @@ func TestWriteFile(t *testing.T) { | |
) | ||
}, | ||
wantJPGs: 2, | ||
wantEmbedded: 1, | ||
wantEmbedded: 2, | ||
wantConv: 1, | ||
}, | ||
{ | ||
|
@@ -103,10 +103,10 @@ func TestWriteFile(t *testing.T) { | |
ofMock.EXPECT().WriteMessage("message2"), | ||
osMock.EXPECT().FileExist("attachment1.heic").Return(true, nil), | ||
osMock.EXPECT().HEIC2JPG("attachment1.heic").Return("attachment1.jpeg", nil), | ||
ofMock.EXPECT().WriteAttachment("attachment1.jpeg"), | ||
ofMock.EXPECT().WriteAttachment("attachment1.jpeg").Return(true, nil), | ||
osMock.EXPECT().FileExist("attachment2.jpeg").Return(true, nil), | ||
osMock.EXPECT().HEIC2JPG("attachment2.jpeg").Return("attachment2.jpeg", nil), | ||
ofMock.EXPECT().WriteAttachment("attachment2.jpeg"), | ||
ofMock.EXPECT().WriteAttachment("attachment2.jpeg").Return(true, nil), | ||
ofMock.EXPECT().Name().Return("messages-export/friend/iMessage;-;[email protected];;;iMessage;-;[email protected]"), | ||
ofMock.EXPECT().ReferenceAttachment("att3transfer.png"), | ||
ofMock.EXPECT().Stage().Return(500, nil), | ||
|
@@ -115,8 +115,9 @@ func TestWriteFile(t *testing.T) { | |
ofMock.EXPECT().Flush(), | ||
) | ||
}, | ||
wantJPGs: 2, | ||
wantConv: 1, | ||
wantJPGs: 2, | ||
wantEmbedded: 2, | ||
wantConv: 1, | ||
}, | ||
{ | ||
msg: "copy attachments", | ||
|
@@ -132,11 +133,11 @@ func TestWriteFile(t *testing.T) { | |
dbMock.EXPECT().GetMessage(2, nil).Return("message2", true, nil), | ||
ofMock.EXPECT().WriteMessage("message2"), | ||
osMock.EXPECT().FileExist("attachment1.heic").Return(true, nil), | ||
osMock.EXPECT().CopyFile("attachment1.heic", "messages-export/friend/attachments", true).Return("attachment1.heic", nil), | ||
ofMock.EXPECT().WriteAttachment("attachment1.heic"), | ||
osMock.EXPECT().CopyFile("attachment1.heic", "messages-export/friend/attachments", true).Return("messages-export/friend/attachments/attachment1.heic", nil), | ||
ofMock.EXPECT().WriteAttachment("messages-export/friend/attachments/attachment1.heic"), | ||
osMock.EXPECT().FileExist("attachment2.jpeg").Return(true, nil), | ||
osMock.EXPECT().CopyFile("attachment2.jpeg", "messages-export/friend/attachments", true).Return("attachment2.jpeg", nil), | ||
ofMock.EXPECT().WriteAttachment("attachment2.jpeg"), | ||
osMock.EXPECT().CopyFile("attachment2.jpeg", "messages-export/friend/attachments", true).Return("messages-export/friend/attachments/attachment2.jpeg", nil), | ||
ofMock.EXPECT().WriteAttachment("messages-export/friend/attachments/attachment2.jpeg"), | ||
ofMock.EXPECT().Name().Return("messages-export/friend/iMessage;-;[email protected];;;iMessage;-;[email protected]"), | ||
ofMock.EXPECT().ReferenceAttachment("att3transfer.png"), | ||
ofMock.EXPECT().Stage(), | ||
|
@@ -161,12 +162,12 @@ func TestWriteFile(t *testing.T) { | |
ofMock.EXPECT().WriteMessage("message2"), | ||
osMock.EXPECT().FileExist("attachment1.heic").Return(true, nil), | ||
osMock.EXPECT().MkdirAll("messages-export/bagoup-attachments", os.ModePerm), | ||
osMock.EXPECT().CopyFile("attachment1.heic", "messages-export/bagoup-attachments", false).Return("attachment1.heic", nil), | ||
ofMock.EXPECT().WriteAttachment("attachment1.heic"), | ||
osMock.EXPECT().CopyFile("attachment1.heic", "messages-export/bagoup-attachments", false).Return("messages-export/bagoup-attachments/attachment1.heic", nil), | ||
ofMock.EXPECT().WriteAttachment("messages-export/bagoup-attachments/attachment1.heic"), | ||
osMock.EXPECT().FileExist("attachment2.jpeg").Return(true, nil), | ||
osMock.EXPECT().MkdirAll("messages-export/bagoup-attachments", os.ModePerm), | ||
osMock.EXPECT().CopyFile("attachment2.jpeg", "messages-export/bagoup-attachments", false).Return("attachment2-1.jpeg", nil), | ||
ofMock.EXPECT().WriteAttachment("attachment2-1.jpeg"), | ||
osMock.EXPECT().CopyFile("attachment2.jpeg", "messages-export/bagoup-attachments", false).Return("messages-export/bagoup-attachments/attachment2-1.jpeg", nil), | ||
ofMock.EXPECT().WriteAttachment("messages-export/bagoup-attachments/attachment2-1.jpeg"), | ||
ofMock.EXPECT().Name().Return("messages-export/friend/iMessage;-;[email protected];;;iMessage;-;[email protected]"), | ||
ofMock.EXPECT().ReferenceAttachment("att3transfer.png"), | ||
ofMock.EXPECT().Stage(), | ||
|
@@ -176,6 +177,39 @@ func TestWriteFile(t *testing.T) { | |
}, | ||
wantJPGs: 1, | ||
}, | ||
{ | ||
msg: "copy attachments and pdf export", | ||
copyAttachments: true, | ||
pdf: true, | ||
setupMocks: func(dbMock *mock_chatdb.MockChatDB, osMock *mock_opsys.MockOS, ofMock *mock_opsys.MockOutFile) { | ||
gomock.InOrder( | ||
osMock.EXPECT().MkdirAll("messages-export/friend", os.ModePerm), | ||
osMock.EXPECT().MkdirAll("messages-export/friend/attachments", os.ModePerm), | ||
osMock.EXPECT().Create("messages-export/friend/iMessage;-;[email protected];;;iMessage;-;[email protected]").Return(chatFile, nil), | ||
osMock.EXPECT().NewPDFOutFile(chatFile, gomock.Any(), false).Return(ofMock), | ||
dbMock.EXPECT().GetMessage(1, nil).Return("message1", true, nil), | ||
ofMock.EXPECT().WriteMessage("message1"), | ||
dbMock.EXPECT().GetMessage(2, nil).Return("message2", true, nil), | ||
ofMock.EXPECT().WriteMessage("message2"), | ||
osMock.EXPECT().FileExist("attachment1.heic").Return(true, nil), | ||
osMock.EXPECT().CopyFile("attachment1.heic", "messages-export/friend/attachments", true).Return("messages-export/friend/attachments/attachment1.heic", nil), | ||
osMock.EXPECT().HEIC2JPG("messages-export/friend/attachments/attachment1.heic").Return("attachment1.jpeg", nil), | ||
ofMock.EXPECT().WriteAttachment("attachment1.jpeg").Return(true, nil), | ||
osMock.EXPECT().FileExist("attachment2.jpeg").Return(true, nil), | ||
osMock.EXPECT().CopyFile("attachment2.jpeg", "messages-export/friend/attachments", true).Return("messages-export/friend/attachments/attachment2.jpeg", nil), | ||
osMock.EXPECT().HEIC2JPG("messages-export/friend/attachments/attachment2.jpeg").Return("messages-export/friend/attachments/attachment2.jpeg", nil), | ||
ofMock.EXPECT().WriteAttachment("messages-export/friend/attachments/attachment2.jpeg").Return(true, nil), | ||
ofMock.EXPECT().Name().Return("messages-export/friend/iMessage;-;[email protected];;;iMessage;-;[email protected]"), | ||
ofMock.EXPECT().ReferenceAttachment("att3transfer.png"), | ||
ofMock.EXPECT().Stage(), | ||
osMock.EXPECT().GetOpenFilesLimit().Return(256, nil), | ||
ofMock.EXPECT().Flush(), | ||
) | ||
}, | ||
wantJPGs: 2, | ||
wantEmbedded: 2, | ||
wantConv: 1, | ||
}, | ||
{ | ||
msg: "chat directory creation error", | ||
pdf: true, | ||
|
@@ -451,8 +485,8 @@ func TestWriteFile(t *testing.T) { | |
dbMock.EXPECT().GetMessage(2, nil).Return("message2", true, nil), | ||
ofMock.EXPECT().WriteMessage("message2"), | ||
osMock.EXPECT().FileExist("attachment1.heic").Return(true, nil), | ||
osMock.EXPECT().CopyFile("attachment1.heic", "messages-export/friend/attachments", true).Return("attachment1.heic", nil), | ||
ofMock.EXPECT().WriteAttachment("attachment1.heic"), | ||
osMock.EXPECT().CopyFile("attachment1.heic", "messages-export/friend/attachments", true).Return("messages-export/friend/attachments/attachment1.heic", nil), | ||
ofMock.EXPECT().WriteAttachment("messages-export/friend/attachments/attachment1.heic"), | ||
osMock.EXPECT().FileExist("attachment2.jpeg").Return(true, nil), | ||
osMock.EXPECT().CopyFile("attachment2.jpeg", "messages-export/friend/attachments", true).Return("", errors.New("this is a permissions error")), | ||
ofMock.EXPECT().Name().Return("messages-export/friend/iMessage;-;[email protected];;;iMessage;-;[email protected]"), | ||
|