1 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 use PublicInbox::TestCommon;
6 use PublicInbox::InboxWritable;
8 require_mods(qw(DBD::SQLite));
9 require PublicInbox::SearchIdx;
11 my $addr = 'test@example.com';
12 my $bad = PublicInbox::MIME->new(<<EOF);
13 Message-ID: <a\@example.com>
14 Message-ID: <b\@example.com>
17 Date: Fri, 02 Oct 1993 00:00:00 +0000
22 my $good = PublicInbox::MIME->new(<<EOF);
23 Message-ID: <b\@example.com>
24 Date: Fri, 02 Oct 1993 00:00:00 +0000
31 for my $order ([$bad, $good], [$good, $bad]) {
33 my ($tmpdir, $for_destroy) = tmpdir();
34 my $ibx = PublicInbox::InboxWritable->new({
35 inboxdir => "$tmpdir/v1",
37 indexlevel => 'basic',
38 -primary_address => $addr,
39 }, my $creat_opt = {});
40 if ('setup v1 inbox') {
41 my $im = $ibx->importer(0);
42 ok($im->add($_), 'added '.$_->header('Subject')) for @$order;
44 my $s = PublicInbox::SearchIdx->new($ibx, 1);
46 $before = [ $ibx->mm->minmax ];
49 my $rdr = { 1 => \(my $out = ''), 2 => \(my $err = '') };
50 my $cmd = [ '-convert', $ibx->{inboxdir}, "$tmpdir/v2" ];
51 my $env = { PI_DIR => "$tmpdir/.public-inbox" };
52 ok(run_script($cmd, $env, $rdr), 'convert to v2');
53 $err =~ s!\AW: $tmpdir/v1 not configured[^\n]+\n!!s;
54 is($err, '', 'no errors or warnings from -convert');
56 $ibx->{inboxdir} = "$tmpdir/v2";
57 is_deeply([$ibx->mm->minmax], $before,
58 'min, max article numbers unchanged');