]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/extsearch.t
extindex: implement --dedupe to fix old extindices
[public-inbox.git] / t / extsearch.t
index 2c3f7547f76f2e17118326b75271c5fc4cb27c37..5f0cd8662bfc0a102bbc32223e4c42a0fa199a30 100644 (file)
@@ -5,16 +5,16 @@ use strict;
 use Test::More;
 use PublicInbox::TestCommon;
 use PublicInbox::Config;
-use PublicInbox::Search;
 use PublicInbox::InboxWritable;
 use Fcntl qw(:seek);
 require_git(2.6);
 require_mods(qw(json DBD::SQLite Search::Xapian));
+require PublicInbox::Search;
 use_ok 'PublicInbox::ExtSearch';
 use_ok 'PublicInbox::ExtSearchIdx';
 use_ok 'PublicInbox::OverIdx';
 my $sock = tcp_server();
-my $host_port = $sock->sockhost . ':' . $sock->sockport;
+my $host_port = tcp_host_port($sock);
 my ($home, $for_destroy) = tmpdir();
 local $ENV{HOME} = $home;
 mkdir "$home/.public-inbox" or BAIL_OUT $!;
@@ -236,6 +236,7 @@ if ('inject w/o indexing') {
 
 if ('reindex catches missed messages') {
        my $v2ibx = $cfg->lookup_name('v2test');
+       $v2ibx->{-no_fsync} = 1;
        my $im = PublicInbox::InboxWritable->new($v2ibx)->importer(0);
        my $cmt_a = $v2ibx->mm->last_commit_xap($schema_version, 0);
        my $eml = eml_load('t/data/0001.patch');
@@ -296,6 +297,7 @@ if ('reindex catches missed messages') {
 if ('reindex catches content bifurcation') {
        use PublicInbox::MID qw(mids);
        my $v2ibx = $cfg->lookup_name('v2test');
+       $v2ibx->{-no_fsync} = 1;
        my $im = PublicInbox::InboxWritable->new($v2ibx)->importer(0);
        my $eml = eml_load('t/data/message_embed.eml');
        my $cmt_a = $v2ibx->mm->last_commit_xap($schema_version, 0);
@@ -366,4 +368,15 @@ if ('remove v1test and test gc') {
        is(scalar(@it), 1, 'only one inbox left');
 }
 
+if ('dedupe + dry-run') {
+       my @cmd = ('-extindex', "$home/extindex");
+       my $opt = { 2 => \(my $err = '') };
+       ok(run_script([@cmd, '--dedupe'], undef, $opt), '--dedupe');
+       ok(run_script([@cmd, qw(--dedupe --dry-run)], undef, $opt),
+               '--dry-run --dedupe');
+       is $err, '', 'no errors';
+       ok(!run_script([@cmd, qw(--dry-run)], undef, $opt),
+               '--dry-run alone fails');
+}
+
 done_testing;