]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/mda.t
remove Email::Address dependency
[public-inbox.git] / t / mda.t
diff --git a/t/mda.t b/t/mda.t
index 6b7527d4ed71a8b3760e269d3d69d8df20cbbec6..fdba967204c310b333e406aa3f687776e5963be7 100644 (file)
--- a/t/mda.t
+++ b/t/mda.t
@@ -48,6 +48,7 @@ my $mime;
 
 local $ENV{GIT_COMMITTER_NAME} = eval {
        use PublicInbox::MDA;
+       use PublicInbox::Address;
        use Encode qw/encode/;
        my $mbox = 't/utf8.mbox';
        open(my $fh, '<', $mbox) or die "failed to open mbox: $mbox\n";
@@ -57,10 +58,9 @@ local $ENV{GIT_COMMITTER_NAME} = eval {
        $msg = Email::MIME->new($msg->simple->as_string);
 
        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');
+       my $author = PublicInbox::Address::from_name($from);
+       my ($email) = PublicInbox::Address::emails($from);
+       my $date = $msg->header('Date');
 
        is('El&#233;anor',
                encode('us-ascii', my $tmp = $author, Encode::HTMLCREF),
@@ -92,11 +92,10 @@ EOF
        {
                local $ENV{PATH} = $main_path;
                run([$mda], \$in);
-               local $ENV{GIT_DIR} = $maindir;
-               my $rev = `git rev-list HEAD`;
+               my $rev = `git --git-dir=$maindir rev-list HEAD`;
                like($rev, qr/\A[a-f0-9]{40}/, "good revision committed");
                chomp $rev;
-               my $cmt = `git cat-file commit $rev`;
+               my $cmt = `git --git-dir=$maindir cat-file commit $rev`;
                like($cmt, qr/^author Me <me\@example\.com> 0 \+0000\n/m,
                        "author info set correctly");
                like($cmt, qr/^committer test <test-public\@example\.com>/m,
@@ -109,8 +108,7 @@ EOF
                ok(!-e $failbox, "nothing in PI_EMERGENCY before");
                local $ENV{PATH} = $fail_path;
                run([$mda], \$in);
-               local $ENV{GIT_DIR} = $maindir;
-               my @revs = `git rev-list HEAD`;
+               my @revs = `git --git-dir=$maindir rev-list HEAD`;
                is(scalar @revs, 1, "bad revision not committed");
                ok(-s $failbox > 0, "PI_EMERGENCY is written to");
        }
@@ -330,8 +328,7 @@ sub fail_bad_header {
        my ($out, $err) = ("", "");
        local $ENV{PATH} = $main_path;
        run([$mda], \$in, \$out, \$err);
-       local $ENV{GIT_DIR} = $maindir;
-       my $rev = `git rev-list HEAD`;
+       my $rev = `git --git-dir=$maindir rev-list HEAD`;
        chomp $rev;
        is($rev, $good_rev, "bad revision not commited ($msg)");
        ok(-s $failbox > 0, "PI_EMERGENCY is written to ($msg)");