From 4ba7568909fe620ee9fb99cb6bbe058df8c0061c Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 19 Jun 2016 17:55:45 +0100 Subject: AvoidDups role --- t/lib/Test/Sietima.pm | 7 +++++++ t/tests/sietima/role/avoid-dups.t | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 t/tests/sietima/role/avoid-dups.t (limited to 't') diff --git a/t/lib/Test/Sietima.pm b/t/lib/Test/Sietima.pm index 0661786..48c92cc 100644 --- a/t/lib/Test/Sietima.pm +++ b/t/lib/Test/Sietima.pm @@ -48,12 +48,19 @@ sub make_sietima { }); } +my $maybe = sub { + my ($obj,$method,$arg) = @_; + return $obj unless $arg; + return $obj->$method($arg); +}; + sub make_mail { my (%args) = @_; Email::Stuffer ->from($args{from}||'someone@users.example.com') ->to($args{to}||$return_path) + ->$maybe(cc => $args{cc}) ->subject($args{subject}||'Test Message') ->text_body($args{body}||'some simple message') ->email; diff --git a/t/tests/sietima/role/avoid-dups.t b/t/tests/sietima/role/avoid-dups.t new file mode 100644 index 0000000..997f3fd --- /dev/null +++ b/t/tests/sietima/role/avoid-dups.t @@ -0,0 +1,28 @@ +#!perl +use strict; +use warnings; +use 5.020; +use lib 't/lib'; +use Test::Sietima; + +my $s = make_sietima( + with_traits => ['AvoidDups'], + subscribers => [ + 'one@users.example.com', + 'two@users.example.com', + ], +); + +test_sending( + sietima => $s, + mail => { cc => 'one@users.example.com' }, + to => ['two@users.example.com'], +); + +test_sending( + sietima => $s, + mail => { to => $s->return_path . ' one@users.example.com' }, + to => ['two@users.example.com'], +); + +done_testing; -- cgit v1.2.3