X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fv2reindex.t;h=1dcefbe36b0f5bb2f40e42209bb593f15ed13355;hb=dde1b083571ed893cbb1990f01f9e11ed804cba5;hp=a5454a22abf58dd929adff066e9099df775735c4;hpb=861bec7bec5908871e5b0ede244cb1e990a47403;p=public-inbox.git diff --git a/t/v2reindex.t b/t/v2reindex.t index a5454a22..1dcefbe3 100644 --- a/t/v2reindex.t +++ b/t/v2reindex.t @@ -1,4 +1,4 @@ -# Copyright (C) 2018 all contributors +# Copyright (C) 2018-2019 all contributors # License: AGPL-3.0+ use strict; use warnings; @@ -7,6 +7,8 @@ use PublicInbox::MIME; use PublicInbox::ContentId qw(content_digest); use File::Temp qw/tempdir/; use File::Path qw(remove_tree); +require './t/common.perl'; +require_git(2.6); foreach my $mod (qw(DBD::SQLite Search::Xapian)) { eval "require $mod"; @@ -21,6 +23,13 @@ my $ibx_config = { -primary_address => 'test@example.com', indexlevel => 'full', }; +my $agpl = eval { + open my $fh, '<', 'COPYING' or die "can't open COPYING: $!"; + local $/; + <$fh>; +}; +$agpl or die "AGPL or die :P\n"; +my $phrase = q("defending all users' freedom"); my $mime = PublicInbox::MIME->create( header => [ From => 'a@example.com', @@ -28,16 +37,15 @@ my $mime = PublicInbox::MIME->create( Subject => 'this is a subject', Date => 'Fri, 02 Oct 1993 00:00:00 +0000', ], - body => "hello world\n", + body => $agpl, ); -local $ENV{NPROC} = 2; my $minmax; my $msgmap; my ($mark1, $mark2, $mark3, $mark4); { my %config = %$ibx_config; my $ibx = PublicInbox::Inbox->new(\%config); - my $im = PublicInbox::V2Writable->new($ibx, 1); + my $im = PublicInbox::V2Writable->new($ibx, {nproc => 1}); my $im0 = $im->importer(); foreach my $i (1..10) { $mime->header_set('Message-Id', "<$i\@example.com>"); @@ -152,7 +160,7 @@ ok(!-d $xap, 'Xapian directories removed again'); delete $ibx->{mm}; is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); is($ibx->mm->num_highwater, 10, 'num_highwater as expected'); - my $mset = $ibx->search->query('"hello world"', {mset=>1}); + my $mset = $ibx->search->query($phrase, {mset=>1}); isnt($mset->size, 0, "phrase search succeeds on indexlevel=full"); for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ } @@ -183,13 +191,15 @@ ok(!-d $xap, 'Xapian directories removed again'); # not sure why, but Xapian seems to fallback to terms and # phrase searches still work delete $ibx->{search}; - my $mset = $ibx->search->query('"hello world"', {mset=>1}); + my $mset = $ibx->search->query($phrase, {mset=>1}); is($mset->size, 0, 'phrase search does not work on medium'); } - - my $mset = $ibx->search->query('hello world', {mset=>1}); + my $words = $phrase; + $words =~ tr/"'//d; + my $mset = $ibx->search->query($words, {mset=>1}); isnt($mset->size, 0, "normal search works on indexlevel=medium"); for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ } + ok($sizes{full} > $sizes{medium}, 'medium is smaller than full'); @@ -215,8 +225,9 @@ ok(!-d $xap, 'Xapian directories removed again'); delete $ibx->{mm}; is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); is($ibx->mm->num_highwater, 10, 'num_highwater as expected'); - my $mset = $ibx->search->query('hello', {mset=>1}); - is($mset->size, 0, "search fails on indexlevel='basic'"); + + isnt($ibx->search, 'no search for basic'); + for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ } ok($sizes{medium} > $sizes{basic}, 'basic is smaller than medium');