user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 4/4] t/mda.t: avoid needless use of Email::Simple
Date: Tue, 21 Apr 2020 21:16:14 +0000	[thread overview]
Message-ID: <20200421211614.5076-5-e@yhbt.net> (raw)
In-Reply-To: <20200421211614.5076-1-e@yhbt.net>

Totally pointless to create an object only to convert
it back to a raw string for -mda input.
---
 t/mda.t | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/t/mda.t b/t/mda.t
index dc691616..fb505146 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -87,7 +87,7 @@ die $@ if $@;
 	local $ENV{PI_EMERGENCY} = $faildir;
 	local $ENV{HOME} = $home;
 	local $ENV{ORIGINAL_RECIPIENT} = $addr;
-	my $simple = Email::Simple->new(<<EOF);
+	my $in = <<EOF;
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -96,8 +96,6 @@ Subject: hihi
 Date: Thu, 01 Jan 1970 00:00:00 +0000
 
 EOF
-	my $in = $simple->as_string;
-
 	# ensure successful message delivery
 	{
 		local $ENV{PATH} = $main_path;
@@ -177,7 +175,7 @@ Date: deadbeef
 	local $ENV{ORIGINAL_RECIPIENT} = $addr;
 	local $ENV{PATH} = $main_path;
 	my $mid = 'spam-train@example.com';
-	my $simple = Email::Simple->new(<<EOF);
+	my $in = <<EOF;
 From: Spammer <spammer\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -186,8 +184,6 @@ Subject: this message will be trained as spam
 Date: Thu, 01 Jan 1970 00:00:00 +0000
 
 EOF
-	my $in = $simple->as_string;
-
 	{
 		# deliver the spam message, first
 		ok(run_script(['-mda'], undef, { 0 => \$in }));
@@ -214,7 +210,7 @@ EOF
 	local $ENV{ORIGINAL_RECIPIENT} = $addr;
 	local $ENV{PATH} = $main_path;
 	my $mid = 'ham-train@example.com';
-	my $simple = Email::Simple->new(<<EOF);
+	my $in = <<EOF;
 From: False-positive <hammer\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -223,8 +219,6 @@ Subject: this message will be trained as spam
 Date: Thu, 01 Jan 1970 00:00:00 +0000
 
 EOF
-	my $in = $simple->as_string;
-
 	# now train it
 	# these should be overridden
 	local $ENV{GIT_AUTHOR_EMAIL} = 'trainer@example.com';
@@ -288,7 +282,7 @@ EOF
 	local $ENV{PATH} = $main_path;
 	my $list_id = 'foo.example.com';
 	my $mid = 'list-id-delivery@example.com';
-	my $simple = Email::Simple->new(<<EOF);
+	my $in = <<EOF;
 From: user <user\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -300,7 +294,6 @@ Date: Thu, 01 Jan 1970 00:00:00 +0000
 EOF
 	xsys(qw(git config --file), $pi_config, "$cfgpfx.listid", $list_id);
 	$? == 0 or die "failed to set listid $?";
-	my $in = $simple->as_string;
 	ok(run_script(['-mda'], undef, { 0 => \$in }),
 		'mda OK with List-Id match');
 	my $path = mid2path($mid);
@@ -308,13 +301,12 @@ EOF
 	like($$msg, qr/\Q$list_id\E/, 'delivered message w/ List-ID matches');
 
 	# try a message w/o precheck
-	$simple = Email::Simple->new(<<EOF);
+	$in = <<EOF;
 To: You <you\@example.com>
 List-Id: <$list_id>
 
 this message would not be accepted without --no-precheck
 EOF
-	$in = $simple->as_string;
 	my ($out, $err) = ('', '');
 	my $rdr = { 0 => \$in, 1 => \$out, 2 => \$err };
 	ok(run_script(['-mda', '--no-precheck'], undef, $rdr),

      parent reply	other threads:[~2020-04-21 21:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 21:16 [PATCH 0/4] some test cleanups Eric Wong
2020-04-21 21:16 ` [PATCH 1/4] t/feed: remove useless $ENV{GIT_DIR} assignment Eric Wong
2020-04-21 21:16 ` [PATCH 2/4] t/*.t: use Email::MIME->create over PublicInbox::MIME->create Eric Wong
2020-04-21 21:16 ` [PATCH 3/4] t/*.t: reduce dependency on Email::MIME APIs Eric Wong
2020-04-21 21:16 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200421211614.5076-5-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).