X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=t%2Fwatch_maildir_v2.t;h=99551ceb7d51191c8dac2cab0482ed50e013bac2;hp=b2cff4bac5b91439d60f5847a83a77d9374264a5;hb=7e881ac8227d1882c92de6f6701ffcba7cef9191;hpb=e220b8b2ee5cfd458167dc2c6c92726352c4c80e
diff --git a/t/watch_maildir_v2.t b/t/watch_maildir_v2.t
index b2cff4ba..99551ceb 100644
--- a/t/watch_maildir_v2.t
+++ b/t/watch_maildir_v2.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2018 all contributors
+# Copyright (C) 2018-2019 all contributors
# License: AGPL-3.0+
use Test::More;
use File::Temp qw/tempdir/;
@@ -40,14 +40,14 @@ ok(POSIX::mkfifo("$maildir/cur/fifo", 0777),
'create FIFO to ensure we do not get stuck on it :P');
my $sem = PublicInbox::Emergency->new($spamdir); # create dirs
-my %orig = (
- "$cfgpfx.address" => $addr,
- "$cfgpfx.mainrepo" => $mainrepo,
- "$cfgpfx.watch" => "maildir:$maildir",
- "$cfgpfx.filter" => 'PublicInbox::Filter::Vger',
- "publicinboxlearn.watchspam" => "maildir:$spamdir"
-);
-my $config = PublicInbox::Config->new({%orig});
+my $orig = <new(\$orig);
my $ibx = $config->lookup_name('test');
ok($ibx, 'found inbox by name');
my $srch = $ibx->search;
@@ -146,12 +146,12 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
my $v1pfx = "publicinbox.v1";
my $v1addr = 'v1-public@example.com';
is(system(qw(git init -q --bare), $v1repo), 0, 'v1 init OK');
- my $config = PublicInbox::Config->new({
- %orig,
- "$v1pfx.address" => $v1addr,
- "$v1pfx.mainrepo" => $v1repo,
- "$v1pfx.watch" => "maildir:$maildir",
- });
+ my $cfg2 = <new(\$cfg2);
my $both = <
+List-Id:
+Message-ID:
+EOF
+ my $do_not_want = <<'EOF';
+From:
+List-Id:
+X-Mailing-List: no@example.com
+Message-ID:
+EOF
+ my $cfg = $orig."$cfgpfx.listid=i.want.you.to.want.me\n";
+ PublicInbox::Emergency->new($maildir)->prepare(\$want);
+ PublicInbox::Emergency->new($maildir)->prepare(\$do_not_want);
+ my $config = PublicInbox::Config->new(\$cfg);
+ PublicInbox::WatchMaildir->new($config)->scan('full');
+ $ibx = $config->lookup_name('test');
+ my $num = $ibx->mm->num_for('do.want@example.com');
+ ok(defined $num, 'List-ID matched for watch');
+ $num = $ibx->mm->num_for('do.not.want@example.com');
+ is($num, undef, 'unaccepted List-ID matched for watch');
+
+ $cfg = $orig."$cfgpfx.watchheader=X-Mailing-List:no\@example.com\n";
+ $config = PublicInbox::Config->new(\$cfg);
+ PublicInbox::WatchMaildir->new($config)->scan('full');
+ $ibx = $config->lookup_name('test');
+ $num = $ibx->mm->num_for('do.not.want@example.com');
+ ok(defined $num, 'X-Mailing-List matched');
+}
+
done_testing;