about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/lei-q-kw.t13
-rw-r--r--t/lei-q-save.t4
-rw-r--r--t/lei_to_mail.t16
3 files changed, 20 insertions, 13 deletions
diff --git a/t/lei-q-kw.t b/t/lei-q-kw.t
index c00a0a43..074c573d 100644
--- a/t/lei-q-kw.t
+++ b/t/lei-q-kw.t
@@ -14,7 +14,6 @@ my $exp = {
         '<testmessage@example.com>' => eml_load('t/utf8.eml'),
 };
 $exp->{'<qp@example.com>'}->header_set('Status', 'RO');
-$exp->{'<testmessage@example.com>'}->header_set('Status', 'O');
 
 test_lei(sub {
 lei_ok(qw(import -F eml t/plack-qp.eml));
@@ -105,7 +104,17 @@ for my $sfx ('', '.gz') {
         my %res;
         PublicInbox::MboxReader->mboxrd($fh, sub {
                 my ($eml) = @_;
-                $res{$eml->header_raw('Message-ID')} = $eml;
+                my $mid = $eml->header_raw('Message-ID');
+                if ($mid eq '<testmessage@example.com>') {
+                        is_deeply([$eml->header('Status')], [],
+                                "no status $sfx");
+                        $eml->header_set('Status');
+                } elsif ($mid eq '<qp@example.com>') {
+                        is($eml->header('Status'), 'RO', 'status preserved');
+                } else {
+                        fail("unknown mid $mid");
+                }
+                $res{$mid} = $eml;
         });
         is_deeply(\%res, $exp, '--augment worked');
 
diff --git a/t/lei-q-save.t b/t/lei-q-save.t
index 753d5b20..aed38a51 100644
--- a/t/lei-q-save.t
+++ b/t/lei-q-save.t
@@ -42,7 +42,7 @@ test_lei(sub {
         lei_ok qw(up -q md -C), $home;
         lei_ok qw(up -q . -C), "$home/md";
         lei_ok qw(up -q), "/$home/md";
-        my %after = map { $_ => 1 } glob("$home/md/cur/*");
+        my %after = map { $_ => 1 } glob("$home/md/{new,cur}/*");
         is(delete $after{(keys(%before))[0]}, 1, 'original message kept');
         is(scalar(keys %after), 1, 'one new message added');
         is_deeply(eml_load((keys %after)[0]), $doc2, 'doc2 matches');
@@ -155,7 +155,7 @@ test_lei(sub {
         $im->add(PublicInbox::Eml->new($diff));
         $im->done;
         lei_ok('up', $o);
-        @m = glob("$o/cur/*");
+        @m = glob("$o/{new,cur}/*");
         is(scalar(@m), 2, 'got 2nd result due to different OID');
 
         SKIP: {
diff --git a/t/lei_to_mail.t b/t/lei_to_mail.t
index 32532a98..35904706 100644
--- a/t/lei_to_mail.t
+++ b/t/lei_to_mail.t
@@ -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,13 +119,12 @@ 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;
 };
 
@@ -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;