-# Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
+# Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
use strict;
use warnings;
use File::Temp qw/tempdir/;
use Cwd;
use IPC::Run qw(run);
+use PublicInbox::MID qw(mid2path);
my $mda = "blib/script/public-inbox-mda";
my $learn = "blib/script/public-inbox-learn";
-my $tmpdir = tempdir(CLEANUP => 1);
+my $tmpdir = tempdir('pi-mda-XXXXXX', TMPDIR => 1, CLEANUP => 1);
my $home = "$tmpdir/pi-home";
my $pi_home = "$home/.public-inbox";
my $pi_config = "$pi_home/config";
close $fh;
my $msg = Email::Filter->new(data => $str);
$msg = Email::MIME->new($msg->simple->as_string);
- my ($author, $email, $date) = PublicInbox::MDA->author_info($msg);
+
+ my $from = $msg->header('From');
+ my @from = Email::Address->parse($from);
+ my $author = $from[0]->name;
+ my $email = $from[0]->address;
+ my $date = $msg ->header('Date');
+
is('Eléanor',
encode('us-ascii', my $tmp = $author, Encode::HTMLCREF),
'HTML conversion is correct');
{
# deliver the spam message, first
run([$mda], \$in);
- my $msg = `ssoma cat $mid $maindir`;
+ my $path = mid2path($mid);
+ my $msg = `git --git-dir=$maindir cat-file blob HEAD:$path`;
like($msg, qr/\Q$mid\E/, "message delivered");
# now train it
run([$learn, "ham"], \$in);
is($?, 0, "learned ham without failure");
- my $msg = `ssoma cat $mid $maindir`;
+ my $path = mid2path($mid);
+ my $msg = `git --git-dir=$maindir cat-file blob HEAD:$path`;
like($msg, qr/\Q$mid\E/, "ham message delivered");
run([$learn, "ham"], \$in);
is($?, 0, "learned ham idempotently ");
$in = $mime->as_string;
run([$learn, "ham"], \$in);
is($?, 0, "learned ham without failure");
- $msg = `ssoma cat $mid $maindir`;
+ my $path = mid2path($mid);
+ $msg = `git --git-dir=$maindir cat-file blob HEAD:$path`;
like($msg, qr/<\Q$mid\E>/, "ham message delivered");
unlike($msg, qr/<html>/i, '<html> filtered');
}