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;
8 my $s = eml_load('t/plack-qp.eml')->as_string;
9 lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
10 lei_ok qw(q z:0.. -f mboxcl2 -o), "$ENV{HOME}/a.mbox.gz";
11 lei_ok qw(q z:0.. -f mboxcl2 -o), "$ENV{HOME}/b.mbox.gz";
12 lei_ok qw(q z:0.. -f mboxcl2 -o), "$ENV{HOME}/a";
13 lei_ok qw(q z:0.. -f mboxcl2 -o), "$ENV{HOME}/b";
15 $s = eml_load('t/utf8.eml')->as_string;
16 lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
17 lei_ok qw(up --all=local);
18 open my $fh, "$ENV{HOME}/a.mbox.gz" or xbail "open: $!";
19 my $gz = do { local $/; <$fh> };
21 gunzip(\$gz => \$uc, MultiStream => 1) or xbail "gunzip $GunzipError";
22 open $fh, "$ENV{HOME}/a" or xbail "open: $!";
24 my $exp = do { local $/; <$fh> };
25 is($uc, $exp, 'compressed and uncompressed match (a.gz)');
26 like($exp, qr/testmessage\@example.com/, '2nd message added');
27 open $fh, "$ENV{HOME}/b.mbox.gz" or xbail "open: $!";
29 $gz = do { local $/; <$fh> };
31 gunzip(\$gz => \$uc, MultiStream => 1) or xbail "gunzip $GunzipError";
32 is($uc, $exp, 'compressed and uncompressed match (b.gz)');
34 open $fh, "$ENV{HOME}/b" or xbail "open: $!";
35 $uc = do { local $/; <$fh> };
36 is($uc, $exp, 'uncompressed both match');
38 lei_ok [ 'up', "$ENV{HOME}/b", "--mua=touch $ENV{HOME}/c" ],
39 undef, { run_mode => 0 };
40 ok(-f "$ENV{HOME}/c", '--mua works with single output');