X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Flei_mail_sync.t;h=74a6c8aae37d40f2b2c969a5d7cd87c8ae4977e4;hb=dfb7216697548f294259cb010c26416cdbbe0ff0;hp=5daa49cd9e6c233e69a42caf8c4e10aea8c0aa55;hpb=4853dee600d76ed5de5807605fa78bcd0557babd;p=public-inbox.git
diff --git a/t/lei_mail_sync.t b/t/lei_mail_sync.t
index 5daa49cd..74a6c8aa 100644
--- a/t/lei_mail_sync.t
+++ b/t/lei_mail_sync.t
@@ -1,5 +1,5 @@
#!perl -w
-# Copyright (C) 2021 all contributors
+# Copyright (C) all contributors
# License: AGPL-3.0+
use strict;
use v5.10.1;
@@ -9,18 +9,18 @@ require_ok 'PublicInbox::LeiMailSync';
my ($dir, $for_destroy) = tmpdir();
my $lms = PublicInbox::LeiMailSync->new("$dir/t.sqlite3");
-$lms->lms_begin;
-$lms->lms_commit;
+$lms->lms_write_prepare;
my $ro = PublicInbox::LeiMailSync->new("$dir/t.sqlite3");
is_deeply([$ro->folders], [], 'no folders, yet');
my $imap = 'imaps://bob@[::1]/INBOX;UIDVALIDITY=9';
-$lms->lms_begin;
+$lms->lms_write_prepare;
my $deadbeef = "\xde\xad\xbe\xef";
is($lms->set_src($deadbeef, $imap, 1), 1, 'set IMAP once');
ok($lms->set_src($deadbeef, $imap, 1) == 0, 'set IMAP idempotently');
-$lms->lms_commit;
is_deeply([$ro->folders], [$imap], 'IMAP folder added');
+note explain([$ro->folders($imap)]);
+note explain([$imap, [$ro->folders]]);
is_deeply([$ro->folders($imap)], [$imap], 'IMAP folder with full GLOB');
is_deeply([$ro->folders('imaps://bob@[::1]/INBOX')], [$imap],
'IMAP folder with partial GLOB');
@@ -30,24 +30,22 @@ is_deeply($ro->locations_for($deadbeef),
my $maildir = 'maildir:/home/user/md';
my $fname = 'foo:2,S';
-$lms->lms_begin;
+$lms->lms_write_prepare;
ok($lms->set_src($deadbeef, $maildir, \$fname), 'set Maildir once');
ok($lms->set_src($deadbeef, $maildir, \$fname) == 0, 'set Maildir again');
-$lms->lms_commit;
is_deeply($ro->locations_for($deadbeef),
{ $imap => [ 1 ], $maildir => [ $fname ] },
'locations_for w/ maildir + imap');
if ('mess things up pretend old bug') {
- $lms->lms_begin;
+ $lms->lms_write_prepare;
+ diag "messing things up";
$lms->{dbh}->do('UPDATE folders SET loc = ? WHERE loc = ?', undef,
"$maildir/", $maildir);
ok(delete $lms->{fmap}, 'clear folder map');
- $lms->lms_commit;
- $lms->lms_begin;
+ $lms->lms_write_prepare;
ok($lms->set_src($deadbeef, $maildir, \$fname), 'set Maildir once');
- $lms->lms_commit;
};
is_deeply([sort($ro->folders)], [$imap, $maildir], 'both folders shown');
@@ -70,12 +68,11 @@ is_deeply($ro->location_stats($maildir), { 'name.count' => 1 },
is_deeply($ro->location_stats($imap),
{ 'uid.count' => 1, 'uid.max' => 1, 'uid.min' => 1 },
'IMAP location stats');
-$lms->lms_begin;
+$lms->lms_write_prepare;
is($lms->clear_src($imap, 1), 1, 'clear_src on IMAP');
is($lms->clear_src($maildir, \$fname), 1, 'clear_src on Maildir');
ok($lms->clear_src($imap, 1) == 0, 'clear_src again on IMAP');
ok($lms->clear_src($maildir, \$fname) == 0, 'clear_src again on Maildir');
-$lms->lms_commit;
is_deeply($ro->location_stats($maildir), {}, 'nothing left');
done_testing;