1 # Copyright (C) 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 plan skip_all => "cannot test $0 as root" if $> == 0;
7 require_mods qw(DBD::SQLite);
8 my ($v2, $v2ro, @v2cfg);
10 my $eml = eml_load 't/plack-qp.eml';
11 my $v1 = create_inbox 'v1', indexlevel => 'basic', tmpdir => "$tmpdir/v1", sub {
16 my $v1ro = create_inbox 'v1ro', indexlevel => 'basic',
17 tmpdir => "$tmpdir/v1ro", sub {
21 chmod 0500, $v1ro->{inboxdir};
22 chmod 0400, glob("$v1ro->{inboxdir}/public-inbox/xapian*/over.sqlite3"),
23 glob("$v1ro->{inboxdir}/public-inbox/msgmap.sqlite3");
27 $v2 = create_inbox 'v2', indexlevel => 'basic', version => 2,
28 tmpdir => "$tmpdir/v2", sub {
32 $v2ro = create_inbox 'v2', indexlevel => 'basic', version => 2,
33 tmpdir => "$tmpdir/v2ro", sub {
37 chmod 0500, $v2ro->{inboxdir}, "$v2ro->{inboxdir}/git/0.git";
38 chmod 0400, glob("$v2ro->{inboxdir}/xap*/over.sqlite3"),
39 glob("$v2ro->{inboxdir}/msgmap.sqlite3");
42 inboxdir = $v2ro->{inboxdir};
43 address = v2ro\@example.com
46 inboxdir = $v2->{inboxdir};
47 address = v2\@example.com
52 my $cfg = cfg_new $tmpdir, <<EOM, @v2cfg;
54 inboxdir = $v1ro->{inboxdir}
55 address = v1ro\@example.com
58 inboxdir = $v1->{inboxdir}
59 address = v1\@example.com
64 0 => \($eml->as_string),
68 my $env = { PI_CONFIG => $cfg->{-f} };
70 run_script [ qw(-learn rm --all -k) ], $env, $opt;
71 isnt $?, 0, 'learn $? is non-zero';
72 is 0, $v1->over->max, 'removed from r/w v1';
73 is 1, $v1ro->over->max, 'not removed from r/o v1';
77 is 0, $v2->over->max, 'removed from r/w v2';
78 is 1, $v2ro->over->max, 'not removed from r/o v2';
82 like $err, qr/E: $nr inbox\(es\) failed/, 'failures noted in stderr';
83 is $out, '', 'stdout is empty';