Skip to content

Commit

Permalink
fixup! fix(outbox): handle indeterminate smtp errors
Browse files Browse the repository at this point in the history
  • Loading branch information
miaulalala committed Apr 19, 2024
1 parent 4aaa31e commit 53e2caf
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions tests/Unit/Send/ChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\Mail\Db\LocalMessageMapper;
use OCA\Mail\Db\MailAccount;
use OCA\Mail\Db\MessageMapper;
use OCA\Mail\Exception\ServiceException;
use OCA\Mail\Send\AntiAbuseHandler;
use OCA\Mail\Send\Chain;
use OCA\Mail\Send\CopySentMessageHandler;
Expand Down Expand Up @@ -79,7 +80,6 @@ public function testProcess(): void {
$expected->setStatus(LocalMessage::STATUS_PROCESSED);
$expected->setId(100);


$this->sentMailboxHandler->expects(self::any())
->method('setNext')
->withConsecutive(
Expand Down Expand Up @@ -116,7 +116,6 @@ public function testProcessNotProcessed() {
$expected->setStatus(LocalMessage::STATUS_IMAP_SENT_MAILBOX_FAIL);
$expected->setId(100);


$this->sentMailboxHandler->expects(self::any())
->method('setNext')
->withConsecutive(
Expand All @@ -139,4 +138,37 @@ public function testProcessNotProcessed() {

$this->chain->process($account, $localMessage);
}

public function testProcessDontProcessErrorerdMessages() {
$mailAccount = new MailAccount();
$mailAccount->setSentMailboxId(1);
$mailAccount->setUserId('bob');
$account = new Account($mailAccount);
$localMessage = new LocalMessage();
$localMessage->setId(100);
$localMessage->setStatus(LocalMessage::STATUS_ERROR);
$expected = new LocalMessage();
$expected->setStatus(LocalMessage::STATUS_IMAP_SENT_MAILBOX_FAIL);
$expected->setId(100);

$this->sentMailboxHandler->expects(self::any())
->method('setNext')
->withConsecutive(
[$this->antiAbuseHandler],
[$this->sentMailboxHandler],
[$this->copySentMessageHandler],
[$this->flagRepliedMessageHandler],
);
$this->sentMailboxHandler->expects(self::never())
->method('process');
$this->attachmentService->expects(self::never())
->method('deleteLocalMessageAttachments');
$this->localMessageMapper->expects(self::never())
->method('deleteWithRecipients');
$this->localMessageMapper->expects(self::never())
->method('update');

$this->expectException(ServiceException::class);
$this->chain->process($account, $localMessage);
}
}

0 comments on commit 53e2caf

Please sign in to comment.