]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/mda.t
remove ssoma dependency
[public-inbox.git] / t / mda.t
diff --git a/t/mda.t b/t/mda.t
index 67e86f47a18d56b30f626bc343c36b4d6273e7a6..6b7527d4ed71a8b3760e269d3d69d8df20cbbec6 100644 (file)
--- a/t/mda.t
+++ b/t/mda.t
@@ -1,4 +1,4 @@
-# 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;
@@ -8,10 +8,11 @@ use Email::Filter;
 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";
@@ -54,7 +55,13 @@ local $ENV{GIT_COMMITTER_NAME} = eval {
        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&#233;anor',
                encode('us-ascii', my $tmp = $author, Encode::HTMLCREF),
                'HTML conversion is correct');
@@ -174,7 +181,8 @@ EOF
        {
                # 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
@@ -212,7 +220,8 @@ EOF
 
        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 ");
@@ -251,7 +260,8 @@ EOF
                $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');
        }