aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2016-06-19 18:22:14 +0100
committerdakkar <dakkar@thenautilus.net>2016-06-19 18:22:14 +0100
commit1ea33ee05cc3f681be561c6a0b9f87846406c24a (patch)
treeabac91e193385901adccdd42c335c22210184ec2 /t
parentAvoidDups role (diff)
downloadSietima-1ea33ee05cc3f681be561c6a0b9f87846406c24a.tar.gz
Sietima-1ea33ee05cc3f681be561c6a0b9f87846406c24a.tar.bz2
Sietima-1ea33ee05cc3f681be561c6a0b9f87846406c24a.zip
Debounce role
Diffstat (limited to 't')
-rw-r--r--t/lib/Test/Sietima.pm10
-rw-r--r--t/tests/sietima/role/debounce.t45
2 files changed, 55 insertions, 0 deletions
diff --git a/t/lib/Test/Sietima.pm b/t/lib/Test/Sietima.pm
index 48c92cc..549d654 100644
--- a/t/lib/Test/Sietima.pm
+++ b/t/lib/Test/Sietima.pm
@@ -54,6 +54,15 @@ my $maybe = sub {
return $obj->$method($arg);
};
+my $mapit = sub {
+ my ($obj,$method,$arg) = @_;
+ return $obj unless $arg;
+ for my $k (keys %{$arg}) {
+ $obj = $obj->$method($k, $arg->{$k});
+ }
+ return $obj;
+};
+
sub make_mail {
my (%args) = @_;
@@ -61,6 +70,7 @@ sub make_mail {
->from($args{from}||'someone@users.example.com')
->to($args{to}||$return_path)
->$maybe(cc => $args{cc})
+ ->$mapit(header => $args{headers})
->subject($args{subject}||'Test Message')
->text_body($args{body}||'some simple message')
->email;
diff --git a/t/tests/sietima/role/debounce.t b/t/tests/sietima/role/debounce.t
new file mode 100644
index 0000000..6021f2b
--- /dev/null
+++ b/t/tests/sietima/role/debounce.t
@@ -0,0 +1,45 @@
+#!perl
+use strict;
+use warnings;
+use 5.020;
+use lib 't/lib';
+use Test::Sietima;
+
+my $s = make_sietima(
+ with_traits => ['Debounce'],
+ subscribers => [
+ 'one@users.example.com',
+ 'two@users.example.com',
+ ],
+);
+
+test_sending(
+ sietima => $s,
+);
+
+my $return_path = $s->return_path->address;
+
+is(
+ [ transport->deliveries ],
+ array {
+ item hash {
+ field email => object {
+ call [cast=>'Email::MIME'] => object {
+ call [ header_str => 'X-Been-There' ] =>
+ match qr{\b\Q$return_path\E\b};
+ };
+ };
+ };
+ },
+ 'header should be added to all messages',
+);
+
+test_sending(
+ sietima => $s,
+ mail => {
+ headers => { 'x-been-there' => $return_path },
+ },
+ to => [],
+);
+
+done_testing;