]> Sergey Matveev's repositories - public-inbox.git/commitdiff
learn: fix buggy typo on List-ID mapping
authorEric Wong <e@yhbt.net>
Tue, 26 May 2020 09:05:23 +0000 (09:05 +0000)
committerEric Wong <e@yhbt.net>
Wed, 27 May 2020 22:31:26 +0000 (22:31 +0000)
There is obviously a typo here, so fix it and add a test
case to guard against future regressions.

Fixes: 74a3206babe0572a ("mda: support multiple List-ID matches")
script/public-inbox-learn
t/mda.t

index a33d813ad01eb389ff5f184f4f98ed6497fba90f..0cb2c8e96e56e706b1e5f158003fa351cf9acc0d 100644 (file)
@@ -97,7 +97,7 @@ if ($train eq 'spam') {
        }
        my $dests = PublicInbox::MDA->inboxes_for_list_id($pi_config, $mime);
        for my $ibx (@$dests) {
-               next if !$seen{"$ibx"}++;
+               next if $seen{"$ibx"}++;
                remove_or_add($ibx, $train, $mime, $ibx->{-primary_address});
        }
 }
diff --git a/t/mda.t b/t/mda.t
index 759c0b020abc661addd2752787e9c95c62ea0b5c..c7caf3e0cca455e3eb40088492b62f26f167ecc4 100644 (file)
--- a/t/mda.t
+++ b/t/mda.t
@@ -299,9 +299,17 @@ EOF
        ok(run_script(['-mda'], undef, $rdr),
                'mda OK with multiple List-Id matches');
        $cur = $git->qx(qw(diff HEAD~1..HEAD));
-       like($cur, qr/Message-ID: <2lids\@example>/,
+       like($cur, qr/^\+Message-ID: <2lids\@example>/sm,
                'multi List-ID match delivered');
        like($err, qr/multiple List-ID/, 'warned about multiple List-ID');
+
+       # ensure -learn rm works after inbox address is updated
+       ($out, $err) = ('', '');
+       xsys(qw(git config --file), $pi_config, "$cfgpfx.address",
+               'updated-address@example.com');
+       ok(run_script(['-learn', 'rm'], undef, $rdr), 'rm-ed via -learn');
+       $cur = $git->qx(qw(diff HEAD~1..HEAD));
+       like($cur, qr/^-Message-ID: <2lids\@example>/sm, 'changed in git');
 }
 
 done_testing();