user/dev discussion of public-inbox itself
 help / color / Atom feed
* [PATCH] t/precheck: remove Email::Simple->create from tests
@ 2020-04-29 11:14 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2020-04-29 11:14 UTC (permalink / raw)
  To: meta

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");
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 11:14 [PATCH] t/precheck: remove Email::Simple->create from tests Eric Wong

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror http://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git