From 34f5eaf6328cf9d6695d5e799e9258aa65c043e4 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 21 Jun 2016 16:36:33 +0100 Subject: role: ReplyTo per-user reply-to munging! also: * deliveries_are can now test whole messages * deliveries_are fails on extra recipients * easier-to-use Subscriber-from-HashRef coercion * nomail.t checks more --- t/lib/Test/Sietima.pm | 60 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 15 deletions(-) (limited to 't/lib/Test/Sietima.pm') diff --git a/t/lib/Test/Sietima.pm b/t/lib/Test/Sietima.pm index 867fd5a..31fb809 100644 --- a/t/lib/Test/Sietima.pm +++ b/t/lib/Test/Sietima.pm @@ -80,26 +80,56 @@ sub deliveries_are { my (%args) = @_; my $ctx = context(); - my $to = $args{to}; - my @recipients = ref($to) ? $to->@* : $to; - my @deliveries = transport->deliveries; - is( - \@deliveries, - array { - if (@recipients) { + + my $checker; + if (my @mails = ($args{mails}||[])->@*) { + $checker = bag { + for my $m (@mails) { item hash { - field envelope => hash { - field from => $args{from}||$return_path; - field to => bag { - for (@recipients) { - item $_; - } + if (ref($m) eq 'HASH') { + field email => object { + call [cast=>'Email::MIME'] => $m->{o}; }; - }; + field envelope => hash { + field to => bag { + item $_ for $m->{to}->@*; + }; + }; + } + else { + field email => object { + call [cast=>'Email::MIME'] => $m; + }; + } }; } end(); - }, + }; + } + elsif (my @recipients = do {my $to = $args{to}; ref($to) ? $to->@* : $to }) { + $checker = array { + item hash { + field envelope => hash { + field from => $args{from}||$return_path; + field to => bag { + for (@recipients) { + item $_; + } + end(); + }; + }; + }; + end(); + }; + } + else { + $checker = []; + } + + my @deliveries = transport->deliveries; + is( + \@deliveries, + $checker, 'the deliveries should be as expected', np @deliveries, ); -- cgit v1.2.3