diff options
Diffstat (limited to 't')
-rw-r--r-- | t/v1reindex.t | 43 | ||||
-rw-r--r-- | t/v2reindex.t | 40 |
2 files changed, 82 insertions, 1 deletions
diff --git a/t/v1reindex.t b/t/v1reindex.t index 0df36d3f..ff32750f 100644 --- a/t/v1reindex.t +++ b/t/v1reindex.t @@ -20,6 +20,7 @@ my $ibx_config = { mainrepo => $mainrepo, name => 'test-v1reindex', -primary_address => 'test@example.com', + indexlevel => 'full', }; my $ibx = PublicInbox::Inbox->new($ibx_config); my $mime = PublicInbox::MIME->create( @@ -74,15 +75,32 @@ is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap'); remove_tree($xap); +ok(!-d $xap, 'Xapian directories removed again'); + $rw = PublicInbox::SearchIdx->new($ibx, 1); +{ + my @warn; + local $SIG{__WARN__} = sub { push @warn, @_ }; + eval { $rw->index_sync({reindex => 1}) }; + is($@, '', 'no error from reindexing without msgmap'); + is(scalar(@warn), 0, 'no warnings from reindexing'); + $im->done; + ok(-d $xap, 'Xapian directories recreated'); + delete $ibx->{mm}; + is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); +} +ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap'); +remove_tree($xap); ok(!-d $xap, 'Xapian directories removed again'); + +$rw = PublicInbox::SearchIdx->new($ibx, 1); { my @warn; local $SIG{__WARN__} = sub { push @warn, @_ }; eval { $rw->index_sync({reindex => 1}) }; is($@, '', 'no error from reindexing without msgmap'); - is(scalar(@warn), 0, 'no warnings from reindexing'); + is_deeply(\@warn, [], 'no warnings'); $im->done; ok(-d $xap, 'Xapian directories recreated'); delete $ibx->{mm}; @@ -91,9 +109,31 @@ ok(!-d $xap, 'Xapian directories removed again'); ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap'); remove_tree($xap); +ok(!-d $xap, 'Xapian directories removed again'); + +$ibx_config->{index_level} = 'medium'; +$ibx = PublicInbox::Inbox->new($ibx_config); $rw = PublicInbox::SearchIdx->new($ibx, 1); +{ + my @warn; + local $SIG{__WARN__} = sub { push @warn, @_ }; + eval { $rw->index_sync({reindex => 1}) }; + is($@, '', 'no error from reindexing without msgmap'); + is_deeply(\@warn, [], 'no warnings'); + $im->done; + ok(-d $xap, 'Xapian directories recreated'); + delete $ibx->{mm}; + is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); +} + +ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap'); +remove_tree($xap); ok(!-d $xap, 'Xapian directories removed again'); + +$ibx_config->{index_level} = 'basic'; +$ibx = PublicInbox::Inbox->new($ibx_config); +$rw = PublicInbox::SearchIdx->new($ibx, 1); { my @warn; local $SIG{__WARN__} = sub { push @warn, @_ }; @@ -106,4 +146,5 @@ ok(!-d $xap, 'Xapian directories removed again'); is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); } + done_testing(); diff --git a/t/v2reindex.t b/t/v2reindex.t index 8af30991..20903967 100644 --- a/t/v2reindex.t +++ b/t/v2reindex.t @@ -19,6 +19,7 @@ my $ibx_config = { name => 'test-v2writable', version => 2, -primary_address => 'test@example.com', + indexlevel => 'full', }; my $ibx = PublicInbox::Inbox->new($ibx_config); my $mime = PublicInbox::MIME->create( @@ -95,4 +96,43 @@ ok(!-d $xap, 'Xapian directories removed again'); is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); } +ok(unlink "$mainrepo/msgmap.sqlite3", 'remove msgmap'); +remove_tree($xap); +ok(!-d $xap, 'Xapian directories removed again'); + +$ibx_config->{index_level} = 'medium'; +$ibx = PublicInbox::Inbox->new($ibx_config); +$im = PublicInbox::V2Writable->new($ibx); +{ + my @warn; + local $SIG{__WARN__} = sub { push @warn, @_ }; + eval { $im->index_sync({reindex => 1}) }; + is($@, '', 'no error from reindexing without msgmap'); + is_deeply(\@warn, [], 'no warnings'); + $im->done; + ok(-d $xap, 'Xapian directories recreated'); + delete $ibx->{mm}; + is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); +} + + +ok(unlink "$mainrepo/msgmap.sqlite3", 'remove msgmap'); +remove_tree($xap); +ok(!-d $xap, 'Xapian directories removed again'); + +$ibx_config->{index_level} = 'basic'; +$ibx = PublicInbox::Inbox->new($ibx_config); +$im = PublicInbox::V2Writable->new($ibx); +{ + my @warn; + local $SIG{__WARN__} = sub { push @warn, @_ }; + eval { $im->index_sync({reindex => 1}) }; + is($@, '', 'no error from reindexing without msgmap'); + is_deeply(\@warn, [], 'no warnings'); + $im->done; + ok(-d $xap, 'Xapian directories recreated'); + delete $ibx->{mm}; + is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); +} + done_testing(); |