X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Freplace.t;h=626cbe9b091bedcc9055c603a35fc262a4f29c81;hb=4eee5af6011cc8cdefb66c9729952c7eff5c0b0b;hp=cef4e7aa6cbe6e57ebaed2c5998a436f62b43f38;hpb=0283273a14e1871955f6a9132f4f3f7884ec8a3f;p=public-inbox.git diff --git a/t/replace.t b/t/replace.t index cef4e7aa..626cbe9b 100644 --- a/t/replace.t +++ b/t/replace.t @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2020 all contributors +# Copyright (C) 2019-2021 all contributors # License: AGPL-3.0+ use strict; use warnings; @@ -20,6 +20,7 @@ sub test_replace ($$$) { inboxdir => "$tmpdir/testbox", name => $this, version => $v, + -no_fsync => 1, -primary_address => 'test@example.com', indexlevel => $level, }); @@ -33,7 +34,7 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000 Top secret info about my house in Malibu... EOF - my $im = PublicInbox::InboxWritable->new($ibx, {nproc=>1})->importer; + my $im = PublicInbox::InboxWritable->new($ibx, {nproc=>1})->importer(0); # fake a bunch of epochs $im->{rotate_bytes} = $opt->{rotate_bytes} if $opt->{rotate_bytes}; @@ -74,7 +75,7 @@ EOF for my $tip (@$cmts) { next if !defined $tip; $changed_epochs++; - like($tip, qr/\A[a-f0-9]{40}\z/, + like($tip, qr/\A[a-f0-9]{40,}\z/, 'replace returned current commit'); } is($changed_epochs, 1, 'only one epoch changed'); @@ -106,8 +107,8 @@ EOF if (my $srch = $ibx->search) { for my $q ('f:streisand', 's:confidential', 'malibu') { - my $msgs = $srch->query($q); - is_deeply($msgs, [], "no match for $q"); + my $mset = $srch->mset($q); + is($mset->size, 0, "no match for $q"); } my @ok = ('f:redactor', 's:redacted', 'nothing to see'); if ($opt->{pre}) { @@ -119,8 +120,8 @@ EOF 's:message3', 's:message4'; } for my $q (@ok) { - my $msgs = $srch->query($q); - ok($msgs->[0], "got match for $q"); + my $mset = $srch->mset($q); + ok($mset->size, "got match for $q"); } } @@ -145,10 +146,12 @@ EOF is($smsg->{subject}, 'redacted', 'after subject'); is($smsg->{mid}, 'replace@example.com', 'before MID'); } + # $git->cleanup; # needed if $im->{parallel}; @warn = (); is($im->replace($orig, $repl), undef, 'no-op replace returns undef'); is($im->purge($orig), undef, 'no-op purge returns undef'); is_deeply(\@warn, [], 'no warnings on noop'); + # $im->done; # needed if $im->{parallel} } sub pad_msgs { @@ -177,20 +180,19 @@ EOF } } -my $opt = { pre => *pad_msgs }; +my $opt = { pre => \&pad_msgs }; test_replace(2, 'basic', {}); test_replace(2, 'basic', $opt); -test_replace(2, 'basic', $opt = { %$opt, post => *pad_msgs }); +test_replace(2, 'basic', $opt = { %$opt, post => \&pad_msgs }); test_replace(2, 'basic', $opt = { %$opt, rotate_bytes => 1 }); SKIP: { - require PublicInbox::Search; - PublicInbox::Search::load_xapian() or skip 'Search::Xapian missing', 8; + require_mods(qw(Search::Xapian), 8); for my $l (qw(medium)) { test_replace(2, $l, {}); - $opt = { pre => *pad_msgs }; + $opt = { pre => \&pad_msgs }; test_replace(2, $l, $opt); - test_replace(2, $l, $opt = { %$opt, post => *pad_msgs }); + test_replace(2, $l, $opt = { %$opt, post => \&pad_msgs }); test_replace(2, $l, $opt = { %$opt, rotate_bytes => 1 }); } };