From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B1F8B1F9E0 for ; Wed, 29 Apr 2020 11:14:43 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] t/precheck: remove Email::Simple->create from tests Date: Wed, 29 Apr 2020 11:14:43 +0000 Message-Id: <20200429111443.14730-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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' => '', - 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: +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' => '', - 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: +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 ', - 'Content-Type' => 'text/plain', - Subject => 'this is a subject', - 'Message-ID' => '', - 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 +Content-Type: text/plain +Subject: this is a subject +Message-ID: +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' => '', - 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: +Date: Wed, 09 Apr 2014 01:28:34 +0000 + +hello world +EOF ok(!PublicInbox::MDA->precheck($s, $recipient), "missing From: is rejected"); }