about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-15 23:36:23 -1200
committerEric Wong <e@80x24.org>2021-01-18 09:25:32 +0000
commit3863b32ecbfb8af20b6650bd134a251a6b290ec7 (patch)
treefe455e057ef52061963af19e31bb1eee9c7954d0 /t
parent15147f7274c34dd5b177a90e9b6f5e86bc86dee3 (diff)
downloadpublic-inbox-3863b32ecbfb8af20b6650bd134a251a6b290ec7.tar.gz
All the augment and deduplication stuff seems to be working
based on unit tests.  OpPipe is a nice general addition that
will probably make future state machines easier.
Diffstat (limited to 't')
-rw-r--r--t/lei.t20
-rw-r--r--t/lei_to_mail.t4
2 files changed, 23 insertions, 1 deletions
diff --git a/t/lei.t b/t/lei.t
index 2349dca4..c4692217 100644
--- a/t/lei.t
+++ b/t/lei.t
@@ -7,6 +7,7 @@ use Test::More;
 use PublicInbox::TestCommon;
 use PublicInbox::Config;
 use File::Path qw(rmtree);
+use Fcntl qw(SEEK_SET);
 require_git 2.6;
 require_mods(qw(json DBD::SQLite Search::Xapian));
 my $opt = { 1 => \(my $out = ''), 2 => \(my $err = '') };
@@ -188,6 +189,25 @@ my $test_external = sub {
         # No double-quoting should be imposed on users on the CLI
         $lei->('q', 's:use boolean prefix');
         like($out, qr/search: use boolean prefix/, 'phrase search got result');
+
+        $lei->('q', '-o', "mboxcl2:$home/mbox", 's:use boolean prefix');
+        open my $mb, '<', "$home/mbox" or fail "no mbox: $!";
+        my @s = grep(/^Subject:/, <$mb>);
+        is(scalar(@s), 1, '1 result in mbox');
+        $lei->('q', '-a', '-o', "mboxcl2:$home/mbox", 's:see attachment');
+        is($err, '', 'no errors from augment');
+        seek($mb, 0, SEEK_SET) or BAIL_OUT "seek: $!";
+        @s = grep(/^Subject:/, <$mb>);
+        is(scalar(@s), 2, '2 results in mbox');
+
+        $lei->('q', '-a', '-o', "mboxcl2:$home/mbox", 's:nonexistent');
+        is($err, '', 'no errors on no results');
+        seek($mb, 0, SEEK_SET) or BAIL_OUT "seek: $!";
+        my @s2 = grep(/^Subject:/, <$mb>);
+        is_deeply(\@s2, \@s, 'same 2 old results w/ --augment and bad search');
+
+        $lei->('q', '-o', "mboxcl2:$home/mbox", 's:nonexistent');
+        is(-s "$home/mbox", 0, 'clobber w/o --augment');
 };
 
 my $test_lei_common = sub {
diff --git a/t/lei_to_mail.t b/t/lei_to_mail.t
index d5beb3d2..083e0df4 100644
--- a/t/lei_to_mail.t
+++ b/t/lei_to_mail.t
@@ -94,7 +94,9 @@ my $wcb_get = sub {
                 my $dup = Storable::thaw(Storable::freeze($l2m));
                 is_deeply($dup, $l2m, "$fmt round-trips through storable");
         }
-        $l2m->do_prepare($lei);
+        $l2m->pre_augment($lei);
+        $l2m->do_augment($lei);
+        $l2m->post_augment($lei);
         my $cb = $l2m->write_cb($lei);
         delete $lei->{1};
         $cb;