From ec6d2dc31406378f77aa681017083fe8e98b4df9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 23 May 2021 01:38:27 +0000 Subject: lei export-kw: support exporting keywords to IMAP We support writing to IMAP stores in other places (just like Maildir), and it's actually less complex for us to write to IMAP. Neither usability nor performance is ideal, but usability will be addressed in the next commit to relax CLI argument checking. Performance is poor due to the synchronous Mail::IMAPClient API and will need to be addressed with pipelining sometime further in the future. --- xt/net_writer-imap.t | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'xt') diff --git a/xt/net_writer-imap.t b/xt/net_writer-imap.t index 1298b958..0e6d4831 100644 --- a/xt/net_writer-imap.t +++ b/xt/net_writer-imap.t @@ -157,12 +157,20 @@ test_lei(sub { lei_ok qw(import -F eml), $f, \'import local copy w/o keywords'; + lei_ok 'ls-mail-sync'; diag $lei_out; + lei_ok 'import', $$folder_uri; # populate mail_sync.sqlite3 + lei_ok qw(tag +kw:seen +kw:answered +kw:flagged), $f; + lei_ok 'ls-mail-sync'; diag $lei_out; + chomp(my $uri_val = $lei_out); + lei_ok 'export-kw', $uri_val; $mic = $nwr->mic_for_folder($folder_uri); - # dummy set to ensure second set_kw clobbers - $nwr->imap_set_kw($mic, $uid[0], [ qw(seen answered flagged) ] - )->expunge or BAIL_OUT "expunge $@"; - $nwr->imap_set_kw($mic, $uid[0], [ 'seen' ] - )->expunge or BAIL_OUT "expunge $@"; + my $flags = $mic->flags($uid[0]); + is_deeply([sort @$flags], [ qw(\\Answered \\Flagged \\Seen) ], + 'IMAP flags set by export-kw') or diag explain($flags); + + # ensure this imap_set_kw clobbers + $nwr->imap_set_kw($mic, $uid[0], [ 'seen' ])->expunge or + BAIL_OUT "expunge $@"; $mic = undef; @res = (); $nwr->imap_each($folder_uri, $imap_slurp_all, \@res); -- cgit v1.2.3-24-ge0c7