about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-05-29 20:20:38 +0000
committerEric Wong <e@80x24.org>2021-05-30 05:02:41 +0000
commit528d69bbbda3cd26d9cc317eff92d21d980b2056 (patch)
tree2d49a4e6cfcc4fd61ffa98ca431619277a1cf606 /t
parent8299d33f315ec2f923dd8b9b45f49403af5912aa (diff)
downloadpublic-inbox-528d69bbbda3cd26d9cc317eff92d21d980b2056.tar.gz
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.
Diffstat (limited to 't')
-rw-r--r--t/lei-import-imap.t13
1 files changed, 12 insertions, 1 deletions
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;