]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/lei_to_mail.t
www: drop --subject from "git send-email" instructions
[public-inbox.git] / t / lei_to_mail.t
index 513572579274fef5f49e7e1cfe14b687f28023b6..e8958c64c46c73b6ae38feeef8718c2b7bd9e2f3 100644 (file)
@@ -75,7 +75,7 @@ for my $mbox (@MBOX) {
 my ($tmpdir, $for_destroy) = tmpdir();
 local $ENV{TMPDIR} = $tmpdir;
 open my $err, '>>', "$tmpdir/lei.err" or BAIL_OUT $!;
-my $lei = bless { 2 => $err }, 'PublicInbox::LEI';
+my $lei = bless { 2 => $err, cmd => 'test' }, 'PublicInbox::LEI';
 my $commit = sub {
        $_[0] = undef; # wcb
        delete $lei->{1};
@@ -90,7 +90,7 @@ my $fn = "$tmpdir/x.mbox";
 my ($mbox) = shuffle(@MBOX); # pick one, shouldn't matter
 my $wcb_get = sub {
        my ($fmt, $dst) = @_;
-       delete $lei->{dedupe};
+       delete $lei->{dedupe}; # to be recreated
        $lei->{ovv} = bless {
                fmt => $fmt,
                dst => $dst
@@ -119,19 +119,18 @@ my $orig = do {
        like($raw, qr/^blah\n/sm, 'wrote content');
        unlink $fn or BAIL_OUT $!;
 
-       local $lei->{opt} = { jobs => 2 };
        $wcb = $wcb_get->($mbox, $fn);
        ok(-f $fn && !-s _, 'truncated mbox destination');
        $wcb->(\($dup = $buf), $deadbeef);
        $commit->($wcb);
        open $fh, '<', $fn or BAIL_OUT $!;
-       is(do { local $/; <$fh> }, $raw, 'jobs > 1');
+       is(do { local $/; <$fh> }, $raw, 'wrote identical content');
        $raw;
 };
 
-test_lei(sub {
-       ok(lei(qw(import -F), $mbox, $fn), 'imported mbox');
-       ok(lei(qw(q s:x)), 'lei q works') or diag $lei_err;
+test_lei({tmpdir => "$tmpdir/using -F"}, sub {
+       lei_ok(qw(import -F), $mbox, $fn, \'imported mbox');
+       lei_ok(qw(q s:x), \'lei q works') or diag $lei_err;
        my $res = json_utf8->decode($lei_out);
        my $x = $res->[0];
        is($x->{'s'}, 'x', 'subject imported') or diag $lei_out;
@@ -139,7 +138,7 @@ test_lei(sub {
        is($res->[1], undef, 'only one result');
 });
 
-test_lei(sub {
+test_lei({tmpdir => "$tmpdir/using TYPE: prefix"}, sub {
        lei_ok('import', "$mbox:$fn", \'imported mbox:/path') or diag $lei_err;
        lei_ok(qw(q s:x), \'lei q works') or diag $lei_err;
        my $res = json_utf8->decode($lei_out);
@@ -158,21 +157,20 @@ for my $zsfx (qw(gz bz2 xz)) {
                ok($dc_cmd, "decompressor for .$zsfx");
                my $f = "$fn.$zsfx";
                my $wcb = $wcb_get->($mbox, $f);
-               $wcb->(\(my $dup = $buf), $deadbeef);
+               $wcb->(\(my $dup = $buf), { %$deadbeef });
                $commit->($wcb);
                my $uncompressed = xqx([@$dc_cmd, $f]);
                is($uncompressed, $orig, "$zsfx works unlocked");
 
-               local $lei->{opt} = { jobs => 2 }; # for atomic writes
                unlink $f or BAIL_OUT "unlink $!";
                $wcb = $wcb_get->($mbox, $f);
-               $wcb->(\($dup = $buf), $deadbeef);
+               $wcb->(\($dup = $buf), { %$deadbeef });
                $commit->($wcb);
                is(xqx([@$dc_cmd, $f]), $orig, "$zsfx matches with lock");
 
                local $lei->{opt} = { augment => 1 };
                $wcb = $wcb_get->($mbox, $f);
-               $wcb->(\($dup = $buf . "\nx\n"), $deadbeef);
+               $wcb->(\($dup = $buf . "\nx\n"), { %$deadbeef });
                $commit->($wcb);
 
                my $cat = popen_rd([@$dc_cmd, $f]);
@@ -182,9 +180,9 @@ for my $zsfx (qw(gz bz2 xz)) {
                like($raw[1], qr/\nblah\n\nx\n\z/s, "augmented $zsfx");
                like($raw[0], qr/\nblah\n\z/s, "original preserved $zsfx");
 
-               local $lei->{opt} = { augment => 1, jobs => 2 };
+               local $lei->{opt} = { augment => 1 };
                $wcb = $wcb_get->($mbox, $f);
-               $wcb->(\($dup = $buf . "\ny\n"), $deadbeef);
+               $wcb->(\($dup = $buf . "\ny\n"), { %$deadbeef });
                $commit->($wcb);
 
                my @raw3;