X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Flei-convert.t;h=0ea860c8218939d8fe22d4887ca6730dc8f17f84;hb=115f68f1e7aff78c27fdeec642e52294fcf20ad8;hp=9b430d8e984d7e2073623779710732422122fc43;hpb=65ec1f78464ce8cf4f6379aca7bbae38743c50f0;p=public-inbox.git diff --git a/t/lei-convert.t b/t/lei-convert.t index 9b430d8e..0ea860c8 100644 --- a/t/lei-convert.t +++ b/t/lei-convert.t @@ -6,8 +6,8 @@ use PublicInbox::MboxReader; use PublicInbox::MdirReader; use PublicInbox::NetReader; use PublicInbox::Eml; -require_git 2.6; -require_mods(qw(DBD::SQLite Search::Xapian Mail::IMAPClient Net::NNTP)); +use IO::Uncompress::Gunzip; +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,7 +57,7 @@ test_lei({ tmpdir => $tmpdir }, sub { lei_ok('convert', '-o', "$d/md", "mboxrd:$d/foo.mboxrd"); ok(-d "$d/md", 'Maildir created'); my @md; - PublicInbox::MdirReader::maildir_each_eml("$d/md", sub { + PublicInbox::MdirReader->new->maildir_each_eml("$d/md", sub { push @md, $_[2]; }); is(scalar(@md), scalar(@mboxrd), 'got expected emails in Maildir') or @@ -92,13 +92,28 @@ test_lei({ tmpdir => $tmpdir }, sub { @bar = (); PublicInbox::MboxReader->mboxcl2($fh, sub { my $eml = shift; - for my $h (qw(Status Content-Length Lines)) { + for my $h (qw(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'); + my $qp_eml = eml_load('t/plack-qp.eml'); + $qp_eml->header_set('Status', 'O'); + is_deeply(\@bar, [ $qp_eml ], 'eml => mboxcl2'); + + lei_ok qw(convert t/plack-qp.eml -o), "mboxrd:$d/qp.gz"; + open $fh, '<', "$d/qp.gz" or xbail $!; + ok(-s $fh, 'not empty'); + $fh = IO::Uncompress::Gunzip->new($fh, MultiStream => 1); + @bar = (); + PublicInbox::MboxReader->mboxrd($fh, sub { push @bar, shift }); + is_deeply(\@bar, [ $qp_eml ], 'wrote gzipped mboxrd'); + lei_ok qw(convert -o mboxrd:/dev/stdout), "mboxrd:$d/qp.gz"; + open $fh, '<', \$lei_out or xbail; + @bar = (); + PublicInbox::MboxReader->mboxrd($fh, sub { push @bar, shift }); + is_deeply(\@bar, [ $qp_eml ], 'readed gzipped mboxrd'); }); done_testing;