2 # Copyright all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict; use v5.10.1; use PublicInbox::TestCommon;
5 use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
7 my ($ro_home, $cfg_path) = setup_public_inboxes;
9 my $qp = eml_load('t/plack-qp.eml');
10 my $s = $qp->as_string;
11 lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
12 lei_ok qw(q z:0.. -f mboxcl2 -o), "$home/a.mbox.gz";
13 lei_ok qw(q z:0.. -f mboxcl2 -o), "$home/b.mbox.gz";
14 lei_ok qw(q z:0.. -f mboxcl2 -o), "$home/a";
15 lei_ok qw(q z:0.. -f mboxcl2 -o), "$home/b";
18 gunzip("$home/$x.mbox.gz" => \$uc, MultiStream => 1) or
19 xbail "gunzip $GunzipError";
20 ok(index($uc, $qp->body_raw) >= 0,
21 "original mail in $x.mbox.gz");
22 open my $fh, '<', "$home/$x" or xbail $!;
23 $uc = do { local $/; <$fh> } // xbail $!;
24 ok(index($uc, $qp->body_raw) >= 0,
25 "original mail in uncompressed $x");
28 $s = eml_load('t/utf8.eml')->as_string;
29 lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
30 lei_ok qw(up --all=local);
32 gunzip("$home/a.mbox.gz" => \$uc, MultiStream => 1) or
33 xbail "gunzip $GunzipError";
35 open my $fh, '<', "$home/a" or xbail "open: $!";
36 my $exp = do { local $/; <$fh> };
37 is($uc, $exp, 'compressed and uncompressed match (a.gz)');
38 like($exp, qr/testmessage\@example.com/, '2nd message added');
41 gunzip("$home/b.mbox.gz" => \$uc, MultiStream => 1) or
42 xbail "gunzip $GunzipError";
43 is($uc, $exp, 'compressed and uncompressed match (b.gz)');
45 open $fh, '<', "$home/b" or xbail "open: $!";
46 $uc = do { local $/; <$fh> };
47 is($uc, $exp, 'uncompressed both match');
49 lei_ok [ qw(up -q), "$home/b", "--mua=touch $home/c" ],
50 undef, { run_mode => 0 };
51 ok(-f "$home/c", '--mua works with single output');