]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/lei-convert.t
test_common: require_mods bundles
[public-inbox.git] / t / lei-convert.t
index 2ba62db3992704a58aa59d9e93a8b865072ed52c..7ff628f9faa3a978084193462480b652752e16f6 100644 (file)
@@ -5,8 +5,8 @@ use strict; use v5.10.1; use PublicInbox::TestCommon;
 use PublicInbox::MboxReader;
 use PublicInbox::MdirReader;
 use PublicInbox::NetReader;
-require_git 2.6;
-require_mods(qw(DBD::SQLite Search::Xapian Mail::IMAPClient Net::NNTP));
+use PublicInbox::Eml;
+require_mods(qw(lei -imapd -nntpd Mail::IMAPClient Net::NNTP));
 my ($tmpdir, $for_destroy) = tmpdir;
 my $sock = tcp_server;
 my $cmd = [ '-imapd', '-W0', "--stdout=$tmpdir/i1", "--stderr=$tmpdir/i2" ];
@@ -57,9 +57,10 @@ test_lei({ tmpdir => $tmpdir }, sub {
        ok(-d "$d/md", 'Maildir created');
        my @md;
        PublicInbox::MdirReader::maildir_each_eml("$d/md", sub {
-               push @md, $_[1];
+               push @md, $_[2];
        });
-       is(scalar(@md), scalar(@mboxrd), 'got expected emails in Maildir');
+       is(scalar(@md), scalar(@mboxrd), 'got expected emails in Maildir') or
+               diag $lei_err;
        @md = sort { ${$a->{bdy}} cmp ${$b->{bdy}} } @md;
        @mboxrd = sort { ${$a->{bdy}} cmp ${$b->{bdy}} } @mboxrd;
        my @rd_nostatus = map {
@@ -84,5 +85,19 @@ test_lei({ tmpdir => $tmpdir }, sub {
        open $fh, '<', "$d/foo.mboxrd" or BAIL_OUT;
        my $exp = do { local $/; <$fh> };
        is($out, $exp, 'stdin => stdout');
+
+       lei_ok qw(convert -F eml -o mboxcl2:/dev/fd/1 t/plack-qp.eml);
+       open $fh, '<', \$lei_out or BAIL_OUT;
+       @bar = ();
+       PublicInbox::MboxReader->mboxcl2($fh, sub {
+               my $eml = shift;
+               for my $h (qw(Status Content-Length Lines)) {
+                       ok(defined($eml->header_raw($h)),
+                               "$h defined for mboxcl2");
+                       $eml->header_set($h);
+               }
+               push @bar, $eml;
+       });
+       is_deeply(\@bar, [ eml_load('t/plack-qp.eml') ], 'eml => mboxcl2');
 });
 done_testing;