From 5759c29ba5e0c8b2b1135e528e133dc7dde219f8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 21 Jun 2020 00:21:33 +0000 Subject: init: add --skip-artnum parameter For archivists with only newer mail archives, this option allows reserving reserve NNTP article numbers for yet-to-be-archived old messages. Indexers will need to be updated to support this feature in future commits. -V1 inboxes will now be initialized with SQLite and Xapian support if this option is used, or if --indexlevel= is specified. --- t/init.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 't/init.t') diff --git a/t/init.t b/t/init.t index 94c6184e..e3e8a229 100644 --- a/t/init.t +++ b/t/init.t @@ -93,12 +93,38 @@ SKIP: { is_deeply($gits, ["$tmpdir/skip1/git/1.git"], 'skip OK'); } - $cmd = [ '-init', '-V2', '--skip-epoch=2', 'skip2', "$tmpdir/skip2", qw(http://example.com/skip2 skip2@example.com) ]; ok(run_script($cmd), "--skip-epoch 2"); my $gits = [ glob("$tmpdir/skip2/git/*.git") ]; is_deeply($gits, ["$tmpdir/skip2/git/2.git"], 'skipping 2 works, too'); + + xsys(qw(git config), "--file=$ENV{PI_DIR}/config", + 'publicinboxmda.spamcheck', 'none') == 0 or + BAIL_OUT "git config $?"; + my $addr = 'skip3@example.com'; + $cmd = [ qw(-init -V2 -Lbasic -N12 skip3), "$tmpdir/skip3", + qw(http://example.com/skip3), $addr ]; + ok(run_script($cmd), '--skip-artnum -V2'); + my $env = { ORIGINAL_RECIPIENT => $addr }; + my $mid = 'skip-artnum@example.com'; + my $msg = "Message-ID: <$mid>\n\n"; + my $rdr = { 0 => \$msg, 2 => \(my $err = '') }; + ok(run_script([qw(-mda --no-precheck)], $env, $rdr), 'deliver V1'); + my $mm = PublicInbox::Msgmap->new_file("$tmpdir/skip3/msgmap.sqlite3"); + my $n = $mm->num_for($mid); + is($n, 13, 'V2 NNTP article numbers skipped via --skip-artnum'); + + $addr = 'skip4@example.com'; + $env = { ORIGINAL_RECIPIENT => $addr }; + $cmd = [ qw(-init -V1 -N12 -Lmedium skip4), "$tmpdir/skip4", + qw(http://example.com/skip4), $addr ]; + ok(run_script($cmd), '--skip-artnum -V1'); + ok(run_script([qw(-mda --no-precheck)], $env, $rdr), 'deliver V1'); + $mm = PublicInbox::Msgmap->new("$tmpdir/skip4"); + system "find $tmpdir/skip4 >&2"; + $n = $mm->num_for($mid); + is($n, 13, 'V1 NNTP article numbers skipped via --skip-artnum'); } done_testing(); -- cgit v1.2.3-24-ge0c7