]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/lei-import-imap.t
lei: rename ls-sync to ls-mail-sync
[public-inbox.git] / t / lei-import-imap.t
index 4a3bd6d8541a2a923016a3edcd88aa9e024938d0..3a1fff4c32162aecacddf427312e5d0baae96f63 100644 (file)
@@ -22,6 +22,12 @@ test_lei({ tmpdir => $tmpdir }, sub {
        is_deeply(json_utf8->decode($lei_out), {}, 'no inspect stats, yet');
 
        lei_ok('import', $url);
+       lei_ok 'ls-mail-sync';
+       like($lei_out, qr!\A\Q$url\E;UIDVALIDITY=\d+\n\z!, 'ls-mail-sync');
+       chomp(my $u = $lei_out);
+       lei_ok('import', $u, \'UIDVALIDITY match in URL');
+       $u =~ s/;UIDVALIDITY=(\d+)\s*/;UIDVALIDITY=9$1/s;
+       ok(!lei('import', $u), 'UIDVALIDITY mismatch in URL rejected');
 
        lei_ok('inspect', $url);
        my $inspect = json_utf8->decode($lei_out);
@@ -43,12 +49,18 @@ test_lei({ tmpdir => $tmpdir }, sub {
        is_deeply(\%r, { 'HASH' => scalar(@$out) }, 'all hashes');
        lei_ok([qw(tag +kw:seen), $url], undef, undef);
 
-       my $f = "$ENV{HOME}/.local/share/lei/store/net_last.sqlite3";
-       ok(-s $f, 'net tracked for redundant imports');
+       my $f = "$ENV{HOME}/.local/share/lei/store/mail_sync.sqlite3";
+       ok(-s $f, 'mail_sync tracked for redundant imports');
        lei_ok('inspect', "blob:$out->[5]->{blob}");
        my $x = json_utf8->decode($lei_out);
        is(ref($x->{'lei/store'}), 'ARRAY', 'lei/store in inspect');
        is(ref($x->{sync}), 'HASH', 'sync in inspect');
        is(ref($x->{sync}->{$k[0]}), 'ARRAY', 'UID arrays in inspect');
+
+       my $psgi_attach = 'cfa3622cbeffc9bd6b0fc66c4d60d420ba74f60d';
+       lei_ok('blob', $psgi_attach);
+       like($lei_out, qr!^Content-Type: multipart/mixed;!sm, 'got full blob');
+       lei_ok('blob', "$psgi_attach:2");
+       is($lei_out, "b64\xde\xad\xbe\xef\n", 'got attachment');
 });
 done_testing;