diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-07-14 17:00:31 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-07-15 09:51:12 +0300 |
commit | dc985a7e9a316bcff0a455f3cfb595f75c687e6b (patch) | |
tree | cc6add1b38d085b431f30409fb11cca47ab90fb8 /tests | |
parent | e18c35d0619d413cdf3fc214c860021d2f05a404 (diff) |
Do not chunk changed/vanished UIDS with QRESYNC
QRESYNC doesn't need the known UIDs as input. In fact it will ignore
the option. As a result the sync will already give an efficient diff of
what really changed. If we still chunk the call it just means that we
will do the exact same operation n times. E.g. on a 600k messages
mailbox the same sync operations is run 60 times.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/IMAP/Sync/SynchronizerTest.php | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/Unit/IMAP/Sync/SynchronizerTest.php b/tests/Unit/IMAP/Sync/SynchronizerTest.php index 7820aa2b1..c16ae4932 100644 --- a/tests/Unit/IMAP/Sync/SynchronizerTest.php +++ b/tests/Unit/IMAP/Sync/SynchronizerTest.php @@ -26,6 +26,7 @@ namespace OCA\Mail\Tests\Unit\IMAP\Sync; use ChristophWurst\Nextcloud\Testing\TestCase; use Horde_Imap_Client; use Horde_Imap_Client_Base; +use Horde_Imap_Client_Data_Capability; use Horde_Imap_Client_Data_Sync; use Horde_Imap_Client_Ids; use Horde_Imap_Client_Mailbox; @@ -52,7 +53,7 @@ class SynchronizerTest extends TestCase { $this->synchronizer = new Synchronizer($this->mapper); } - public function testSync(): void { + public function testSyncWithQresync(): void { $imapClient = $this->createMock(Horde_Imap_Client_Base::class); $request = $this->createMock(Request::class); $request->expects($this->any()) @@ -61,10 +62,16 @@ class SynchronizerTest extends TestCase { $request->expects($this->once()) ->method('getToken') ->willReturn('123456'); - $request->expects($this->once()) - ->method('getUids') - ->willReturn([4,5,6]); $hordeSync = $this->createMock(Horde_Imap_Client_Data_Sync::class); + $capabilities = $this->createMock(Horde_Imap_Client_Data_Capability::class); + $imapClient->expects(self::once()) + ->method('__get') + ->with('capability') + ->willReturn($capabilities); + $capabilities->expects(self::once()) + ->method('isEnabled') + ->with('QRESYNC') + ->willReturn(true); $imapClient->expects($this->once()) ->method('sync') ->with($this->equalTo(new Horde_Imap_Client_Mailbox('inbox')), $this->equalTo('123456')) @@ -96,6 +103,15 @@ class SynchronizerTest extends TestCase { ->willReturn('123456'); $request->method('getUids') ->willReturn(range(1, 30000, 1)); + $capabilities = $this->createMock(Horde_Imap_Client_Data_Capability::class); + $imapClient->expects(self::once()) + ->method('__get') + ->with('capability') + ->willReturn($capabilities); + $capabilities->expects(self::once()) + ->method('isEnabled') + ->with('QRESYNC') + ->willReturn(false); $hordeSync = $this->createMock(Horde_Imap_Client_Data_Sync::class); $imapClient->expects($this->exactly(3)) ->method('sync') |