X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fv1reindex.t;h=13605f8bd6ce5de1915fe7bc58b1a03756377486;hb=0283273a14e1871955f6a9132f4f3f7884ec8a3f;hp=e35477535800626e47bda9bd64546c32d3514098;hpb=3c39f9c942a6975245fda878e9b957d8d3367662;p=public-inbox.git diff --git a/t/v1reindex.t b/t/v1reindex.t index e3547753..13605f8b 100644 --- a/t/v1reindex.t +++ b/t/v1reindex.t @@ -1,38 +1,31 @@ -# Copyright (C) 2018-2019 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; +use PublicInbox::Eml; 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)); use_ok 'PublicInbox::SearchIdx'; use_ok 'PublicInbox::Import'; -my $inboxdir = tempdir('pi-v1reindex-XXXXXX', TMPDIR => 1, CLEANUP => 1); -is(system(qw(git init -q --bare), $inboxdir), 0); +my ($inboxdir, $for_destroy) = tmpdir(); my $ibx_config = { inboxdir => $inboxdir, name => 'test-v1reindex', -primary_address => 'test@example.com', indexlevel => 'full', }; -my $mime = PublicInbox::MIME->create( - header => [ - From => 'a@example.com', - To => 'test@example.com', - Subject => 'this is a subject', - Date => 'Fri, 02 Oct 1993 00:00:00 +0000', - ], - body => "hello world\n", -); +my $mime = PublicInbox::Eml->new(<<'EOF'); +From: a@example.com +To: test@example.com +Subject: this is a subject +Date: Fri, 02 Oct 1993 00:00:00 +0000 + +hello world +EOF my $minmax; my $msgmap; my ($mark1, $mark2, $mark3, $mark4); @@ -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");