about summary refs log tree commit homepage
path: root/t/v2reindex.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-07-19 21:43:10 +0000
committerEric Wong <e@80x24.org>2018-07-19 21:49:10 +0000
commit4caa768779a9b417321736b090d50f3421a799de (patch)
treeef541207838dad1db44295bedadc8f8418d02c23 /t/v2reindex.t
parentce5af2029b6bc703f3d8cf7bb5c68732c41f210e (diff)
downloadpublic-inbox-4caa768779a9b417321736b090d50f3421a799de.tar.gz
The correct field is underscore-less for consistency with
git-config naming conventions.  While we're at it, beef up
the v2 tests with actual size checks, too.

I also noticed phrase searching still seems to work for
the limited test case, so I left it documented; but the
size checking verifies the space savings.
Diffstat (limited to 't/v2reindex.t')
-rw-r--r--t/v2reindex.t26
1 files changed, 23 insertions, 3 deletions
diff --git a/t/v2reindex.t b/t/v2reindex.t
index 20903967..1543309c 100644
--- a/t/v2reindex.t
+++ b/t/v2reindex.t
@@ -81,6 +81,7 @@ ok(!-d $xap, 'Xapian directories removed again');
         is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged');
 }
 
+my %sizes;
 ok(unlink "$mainrepo/msgmap.sqlite3", 'remove msgmap');
 remove_tree($xap);
 ok(!-d $xap, 'Xapian directories removed again');
@@ -94,13 +95,16 @@ ok(!-d $xap, 'Xapian directories removed again');
         ok(-d $xap, 'Xapian directories recreated');
         delete $ibx->{mm};
         is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged');
+        my $mset = $ibx->search->query('"hello world"', {mset=>1});
+        isnt(0, $mset->size, "phrase search succeeds on indexlevel=full");
+        for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ }
 }
 
 ok(unlink "$mainrepo/msgmap.sqlite3", 'remove msgmap');
 remove_tree($xap);
 ok(!-d $xap, 'Xapian directories removed again');
 
-$ibx_config->{index_level} = 'medium';
+$ibx_config->{indexlevel} = 'medium';
 $ibx = PublicInbox::Inbox->new($ibx_config);
 $im = PublicInbox::V2Writable->new($ibx);
 {
@@ -113,14 +117,26 @@ $im = PublicInbox::V2Writable->new($ibx);
         ok(-d $xap, 'Xapian directories recreated');
         delete $ibx->{mm};
         is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged');
-}
 
+        if (0) {
+                # 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});
+                is(0, $mset->size, 'phrase search does not work on medium');
+        }
+
+        my $mset = $ibx->search->query('hello world', {mset=>1});
+        isnt(0, $mset->size, "normal search works on indexlevel=medium");
+        for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ }
+        ok($sizes{full} > $sizes{medium}, 'medium is smaller than full');
+}
 
 ok(unlink "$mainrepo/msgmap.sqlite3", 'remove msgmap');
 remove_tree($xap);
 ok(!-d $xap, 'Xapian directories removed again');
 
-$ibx_config->{index_level} = 'basic';
+$ibx_config->{indexlevel} = 'basic';
 $ibx = PublicInbox::Inbox->new($ibx_config);
 $im = PublicInbox::V2Writable->new($ibx);
 {
@@ -133,6 +149,10 @@ $im = PublicInbox::V2Writable->new($ibx);
         ok(-d $xap, 'Xapian directories recreated');
         delete $ibx->{mm};
         is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged');
+        my $mset = $ibx->search->query('hello', {mset=>1});
+        is(0, $mset->size, "search fails on indexlevel='basic'");
+        for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ }
+        ok($sizes{medium} > $sizes{basic}, 'basic is smaller than medium');
 }
 
 done_testing();