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] t/precheck: remove Email::Simple->create from tests
Date: Wed, 29 Apr 2020 11:14:43 +0000	[thread overview]
Message-ID: <20200429111443.14730-1-e@yhbt.net> (raw)

It's likely we'll replace Email::Simple using our Email::MIME
alternative/replacement, as well.  So reduce the API surface we
interact with and make it easier to swap implementations.
---
 t/precheck.t | 90 +++++++++++++++++++++++++---------------------------
 1 file changed, 43 insertions(+), 47 deletions(-)

diff --git a/t/precheck.t b/t/precheck.t
index 53d4fb2b..a8fd31b1 100644
--- a/t/precheck.t
+++ b/t/precheck.t
@@ -27,65 +27,61 @@ sub do_checks {
 }
 
 {
-	my $s = Email::Simple->create(
-		header => [
-			From => 'abc@example.com',
-			To => 'abc@example.com',
-			Cc => 'c@example.com, another-list@example.com',
-			'Content-Type' => 'text/plain',
-			Subject => 'list is fine',
-			'Message-ID' => '<MID@host>',
-			Date => 'Wed, 09 Apr 2014 01:28:34 +0000',
-		],
-		body => "hello world\n",
-	);
+	my $s = Email::Simple->new(<<'EOF');
+From: abc@example.com
+To: abc@example.com
+Cc: c@example.com, another-list@example.com
+Content-Type: text/plain
+Subject: list is fine
+Message-ID: <MID@host>
+Date: Wed, 09 Apr 2014 01:28:34 +0000
+
+hello world
+EOF
 	my $addr = [ 'c@example.com', 'd@example.com' ];
 	ok(PublicInbox::MDA->precheck($s, $addr), 'Cc list is OK');
 }
 
 {
-	do_checks(Email::Simple->create(
-		header => [
-			From => 'a@example.com',
-			To => 'b@example.com',
-			Cc => 'c@example.com',
-			'Content-Type' => 'text/plain',
-			Subject => 'this is a subject',
-			'Message-ID' => '<MID@host>',
-			Date => 'Wed, 09 Apr 2014 01:28:34 +0000',
-		],
-		body => "hello world\n",
-	));
+	do_checks(Email::Simple->new(<<'EOF'));
+From: a@example.com
+To: b@example.com
+Cc: c@example.com
+Content-Type: text/plain
+Subject: this is a subject
+Message-ID: <MID@host>
+Date: Wed, 09 Apr 2014 01:28:34 +0000
+
+hello world
+EOF
 }
 
 {
-	do_checks(Email::Simple->create(
-		header => [
-			From => 'a@example.com',
-			To => 'b+plus@example.com',
-			Cc => 'John Doe <c@example.com>',
-			'Content-Type' => 'text/plain',
-			Subject => 'this is a subject',
-			'Message-ID' => '<MID@host>',
-			Date => 'Wed, 09 Apr 2014 01:28:34 +0000',
-		],
-		body => "hello world\n",
-	));
+	do_checks(Email::Simple->new(<<'EOF'));
+From: a@example.com
+To: b+plus@example.com
+Cc: John Doe <c@example.com>
+Content-Type: text/plain
+Subject: this is a subject
+Message-ID: <MID@host>
+Date: Wed, 09 Apr 2014 01:28:34 +0000
+
+hello world
+EOF
 }
 
 {
 	my $recipient = 'b@example.com';
-	my $s = Email::Simple->create(
-		header => [
-			To => 'b@example.com',
-			Cc => 'c@example.com',
-			'Content-Type' => 'text/plain',
-			Subject => 'this is a subject',
-			'Message-ID' => '<MID@host>',
-			Date => 'Wed, 09 Apr 2014 01:28:34 +0000',
-		],
-		body => "hello world\n",
-	);
+	my $s = Email::Simple->new(<<'EOF');
+To: b@example.com
+Cc: c@example.com
+Content-Type: text/plain
+Subject: this is a subject
+Message-ID: <MID@host>
+Date: Wed, 09 Apr 2014 01:28:34 +0000
+
+hello world
+EOF
 	ok(!PublicInbox::MDA->precheck($s, $recipient),
 		"missing From: is rejected");
 }

                 reply	other threads:[~2020-04-29 11:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200429111443.14730-1-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).