1 # Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
7 use PublicInbox::Config;
8 use PublicInbox::TestCommon;
10 require_mods(qw(DBD::SQLite Xapian));
11 use_ok 'PublicInbox::V2Writable';
12 my ($tmpdir, $for_destroy) = tmpdir();
13 my $pi_config = "$tmpdir/pi_config";
14 local $ENV{PI_CONFIG} = $pi_config;
15 local $ENV{PI_EMERGENCY} = "$tmpdir/emergency";
16 my @cfg = ('git', 'config', "--file=$pi_config");
17 is(xsys(@cfg, 'publicinboxmda.spamcheck', 'none'), 0);
19 for my $v (qw(V1 V2)) {
21 local $SIG{__WARN__} = sub { push @warn, @_ };
22 my $cfgpfx = "publicinbox.$v";
23 my $inboxdir = "$tmpdir/$v";
24 my $addr = "test-$v\@example.com";
25 my $cmd = [ '-init', "-$v", $v, $inboxdir,
26 "http://example.com/$v", $addr ];
27 ok(run_script($cmd), 'public-inbox-init');
28 ok(run_script([qw(-index -j0), $inboxdir]), 'public-inbox-index');
29 is(xsys(@cfg, "$cfgpfx.filter", 'PublicInbox::Filter::RubyLang'), 0);
30 is(xsys(@cfg, "$cfgpfx.altid",
31 'serial:alerts:file=msgmap.sqlite3'), 0);
34 my $env = { ORIGINAL_RECIPIENT => $addr };
35 my $opt = { 0 => \(<<EOF) };
36 From: user\@example.com
40 Message-Id: <a.$i\@b.com>
41 Date: Sat, 05 Jan 2019 04:19:17 +0000
45 ok(run_script(['-mda'], $env, $opt), 'message delivered');
47 my $cfg = PublicInbox::Config->new;
48 my $ibx = $cfg->lookup_name($v);
50 # make sure all serials are searchable:
52 my $mset = $ibx->search->mset("alerts:$i");
53 is($mset->size, 1, "got one result for alerts:$i");
54 my $msgs = $ibx->search->mset_to_smsg($ibx, $mset);
55 is($msgs->[0]->{mid}, "a.$i\@b.com", "got expected MID for $i");
57 is_deeply([], \@warn, 'no warnings');
59 # TODO: public-inbox-learn doesn't know about filters