X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fv1reindex.t;h=ce3833be35696a8d325bf28540a4f2644870ee7e;hb=62d1a4da996bd9a664be954f71f78fe052f9df16;hp=35275fb49bbdf15a4eef202093ce48db370a541e;hpb=8e08a9ab966eb9c3281c861d0669a2db04442561;p=public-inbox.git
diff --git a/t/v1reindex.t b/t/v1reindex.t
index 35275fb4..ce3833be 100644
--- a/t/v1reindex.t
+++ b/t/v1reindex.t
@@ -1,30 +1,23 @@
-# Copyright (C) 2018 all contributors
+# Copyright (C) 2018-2020 all contributors
# License: AGPL-3.0+
use strict;
use warnings;
use Test::More;
-use PublicInbox::MIME;
use PublicInbox::ContentId qw(content_digest);
-use File::Temp qw/tempdir/;
use File::Path qw(remove_tree);
-require './t/common.perl';
+use PublicInbox::TestCommon;
require_git(2.6);
-
-foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
- eval "require $mod";
- plan skip_all => "$mod missing for v1reindex.t" if $@;
-}
+require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
use_ok 'PublicInbox::SearchIdx';
use_ok 'PublicInbox::Import';
-my $mainrepo = tempdir('pi-v1reindex-XXXXXX', TMPDIR => 1, CLEANUP => 1);
-is(system(qw(git init -q --bare), $mainrepo), 0);
+my ($inboxdir, $for_destroy) = tmpdir();
my $ibx_config = {
- mainrepo => $mainrepo,
+ inboxdir => $inboxdir,
name => 'test-v1reindex',
-primary_address => 'test@example.com',
indexlevel => 'full',
};
-my $mime = PublicInbox::MIME->create(
+my $mime = Email::MIME->create(
header => [
From => 'a@example.com',
To => 'test@example.com',
@@ -40,6 +33,7 @@ my ($mark1, $mark2, $mark3, $mark4);
my %config = %$ibx_config;
my $ibx = PublicInbox::Inbox->new(\%config);
my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
+ $im->init_bare;
foreach my $i (1..10) {
$mime->header_set('Message-Id', "<$i\@example.com>");
ok($im->add($mime), "message $i added");
@@ -96,7 +90,7 @@ my ($mark1, $mark2, $mark3, $mark4);
is_deeply($ibx->mm->msg_range(\$min, $max), $msgmap, 'msgmap unchanged');
}
-my $xap = "$mainrepo/public-inbox/xapian".PublicInbox::Search::SCHEMA_VERSION();
+my $xap = "$inboxdir/public-inbox/xapian".PublicInbox::Search::SCHEMA_VERSION();
remove_tree($xap);
ok(!-d $xap, 'Xapian directories removed');
{
@@ -118,7 +112,7 @@ ok(!-d $xap, 'Xapian directories removed');
is_deeply($ibx->mm->msg_range(\$min, $max), $msgmap, 'msgmap unchanged');
}
-ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap');
+ok(unlink "$inboxdir/public-inbox/msgmap.sqlite3", 'remove msgmap');
remove_tree($xap);
ok(!-d $xap, 'Xapian directories removed again');
{
@@ -141,7 +135,7 @@ ok(!-d $xap, 'Xapian directories removed again');
is_deeply($ibx->mm->msg_range(\$min, $max), $msgmap, 'msgmap unchanged');
}
-ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap');
+ok(unlink "$inboxdir/public-inbox/msgmap.sqlite3", 'remove msgmap');
remove_tree($xap);
ok(!-d $xap, 'Xapian directories removed again');
{
@@ -164,7 +158,7 @@ ok(!-d $xap, 'Xapian directories removed again');
is_deeply($ibx->mm->msg_range(\$min, $max), $msgmap, 'msgmap unchanged');
}
-ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap');
+ok(unlink "$inboxdir/public-inbox/msgmap.sqlite3", 'remove msgmap');
remove_tree($xap);
ok(!-d $xap, 'Xapian directories removed again');
{
@@ -190,7 +184,7 @@ ok(!-d $xap, 'Xapian directories removed again');
is_deeply($ibx->mm->msg_range(\$min, $max), $msgmap, 'msgmap unchanged');
}
-ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap');
+ok(unlink "$inboxdir/public-inbox/msgmap.sqlite3", 'remove msgmap');
remove_tree($xap);
ok(!-d $xap, 'Xapian directories removed again');
{
@@ -239,7 +233,7 @@ ok(!-d $xap, 'Xapian directories removed again');
}
# An incremental indexing test
-ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap');
+ok(unlink "$inboxdir/public-inbox/msgmap.sqlite3", 'remove msgmap');
remove_tree($xap);
ok(!-d $xap, 'Xapian directories removed again');
{
@@ -349,7 +343,7 @@ ok(!-d $xap, 'Xapian directories removed again');
# Another incremental indexing test
-ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap');
+ok(unlink "$inboxdir/public-inbox/msgmap.sqlite3", 'remove msgmap');
remove_tree($xap);
ok(!-d $xap, 'Xapian directories removed again');
{