aboutsummaryrefslogtreecommitdiff
path: root/t/tests/sietima.t
diff options
context:
space:
mode:
Diffstat (limited to 't/tests/sietima.t')
-rw-r--r--t/tests/sietima.t77
1 files changed, 6 insertions, 71 deletions
diff --git a/t/tests/sietima.t b/t/tests/sietima.t
index ab6e129..3644763 100644
--- a/t/tests/sietima.t
+++ b/t/tests/sietima.t
@@ -3,52 +3,13 @@ use strict;
use warnings;
use 5.020;
use lib 't/lib';
-use Test2::Bundle::Extended;
-use Test2::Tools::MoreCompare qw(bag);
-use Test2::Plugin::DieOnFail;
-use Email::Stuffer;
-use Email::Sender::Transport::Test;
-use Data::Printer;
-use Sietima;
-
-my $return_path = 'sietima-test@list.example.com',
-my $transport = Email::Sender::Transport::Test->new;
-sub make_sietima {
- $transport->clear_deliveries;
- Sietima->new({
- return_path => $return_path,
- transport => $transport,
- @_,
- });
-}
-
-sub make_mail {
- my (%args) = @_;
- Email::Stuffer
- ->from($args{from}||'someone@users.example.com')
- ->to($args{no}||$return_path)
- ->text_body($args{body}||'some simple message')
- ->email;
-}
+use Test::Sietima;
ok(make_sietima(),'should instantiate') or bail_out;
subtest 'no subscribers' => sub {
- my $s = make_sietima();
- my $m = make_mail();
-
- ok(
- lives { $s->handle_mail($m) },
- 'should handle the mail',
- $@,
- );
-
- my @deliveries = $transport->deliveries;
- is(
- \@deliveries,
- [],
- 'nothing should be delivered',
- np @deliveries,
+ test_sending(
+ to => [],
);
};
@@ -57,35 +18,9 @@ subtest 'with subscribers' => sub {
'one@users.example.com',
'two@users.example.com',
);
- my $s = make_sietima(
- subscribers => [@subscriber_addresses],
- );
- my $m = make_mail();
-
- ok(
- lives { $s->handle_mail($m) },
- 'should handle the mail',
- $@,
- );
-
- my @deliveries = $transport->deliveries;
- is(
- \@deliveries,
- array {
- item hash {
- field envelope => hash {
- field from => $return_path;
- field to => bag {
- for (@subscriber_addresses) {
- item object { call address => $_ };
- }
- };
- };
- };
- end();
- },
- 'there should be two deliveries',
- np @deliveries,
+ test_sending(
+ sietima => { subscribers => \@subscriber_addresses },
+ to => \@subscriber_addresses,
);
};