From 528d69bbbda3cd26d9cc317eff92d21d980b2056 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 29 May 2021 20:20:38 +0000 Subject: lei import|lcat: improve+fix single message IMAP support lcat can now dump the memoized contents of entire IMAP folders, not just a single UID. It's now parallelized and pipelined for multiple lei2mail workers. Furthemore, various forms of JSON output work consistently with blob-only output, now. While working on this, I noticed NetReader was passing UID URLs to imap_each callbacks, which was causing mail_sync.sqlite3 to store UIDs in `folders' and clearly wrong so it's now fixed. --- t/lei-import-imap.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/lei-import-imap.t b/t/lei-import-imap.t index 59d481d5..895b19ff 100644 --- a/t/lei-import-imap.t +++ b/t/lei-import-imap.t @@ -48,6 +48,13 @@ test_lei({ tmpdir => $tmpdir }, sub { ok($stats->{'uid.min'} < $stats->{'uid.max'}, 'min < max'); ok($stats->{'uid.count'} > 0, 'count > 0'); + lei_ok('lcat', $url); + is(scalar(grep(/^# blob:/, split(/\n/ms, $lei_out))), + $stats->{'uid.count'}, 'lcat on URL dumps folder'); + lei_ok qw(lcat -f json), $url; + $out = json_utf8->decode($lei_out); + is(scalar(@$out) - 1, $stats->{'uid.count'}, 'lcat JSON dumps folder'); + lei_ok(qw(q z:1..)); $out = json_utf8->decode($lei_out); ok(scalar(@$out) > 1, 'got imported messages'); @@ -77,6 +84,8 @@ test_lei({ tmpdir => $tmpdir }, sub { unlike($lei_out, qr!\Q$host_port\E!, 'sync info gone after forget'); my $uid_url = "$url/;UID=".$stats->{'uid.max'}; lei_ok 'import', $uid_url; + lei_ok 'ls-mail-sync'; + is($lei_out, "$url\n", 'ls-mail-sync added URL w/o UID'); lei_ok 'inspect', $uid_url; $lei_out =~ /([a-f0-9]{40,})/ or xbail 'inspect missed blob with UID URL'; @@ -88,7 +97,9 @@ test_lei({ tmpdir => $tmpdir }, sub { my $orig = $lei_out; lei_ok 'lcat', "blob:$blob"; is($lei_out, $orig, 'lcat understands blob:...'); - ok(!lei('lcat', $url), "lcat doesn't work on IMAP URL w/o UID"); + lei_ok qw(lcat -f json), $uid_url; + $out = json_utf8->decode($lei_out); + is(scalar(@$out), 2, 'got JSON') or diag explain($out); }); done_testing; -- cgit v1.2.3-24-ge0c7