aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2016-06-21 16:45:55 +0100
committerdakkar <dakkar@thenautilus.net>2016-06-21 16:55:21 +0100
commit637013159f49e52f7464ea8e6173a9e236112410 (patch)
tree9685145635e51b0e1ab1a09b17fdbb02073eb051 /t
parentignore editor backup files (diff)
downloadSietima-637013159f49e52f7464ea8e6173a9e236112410.tar.gz
Sietima-637013159f49e52f7464ea8e6173a9e236112410.tar.bz2
Sietima-637013159f49e52f7464ea8e6173a9e236112410.zip
use the new deliveries comparator
Diffstat (limited to 't')
-rw-r--r--t/tests/sietima/role/avoid-dups.t24
-rw-r--r--t/tests/sietima/role/debounce.t45
-rw-r--r--t/tests/sietima/role/subject-tag.t45
-rw-r--r--t/tests/sietima/role/subscriberonly/moderate.t42
4 files changed, 63 insertions, 93 deletions
diff --git a/t/tests/sietima/role/avoid-dups.t b/t/tests/sietima/role/avoid-dups.t
index d5fcab3..58cd308 100644
--- a/t/tests/sietima/role/avoid-dups.t
+++ b/t/tests/sietima/role/avoid-dups.t
@@ -13,16 +13,20 @@ my $s = make_sietima(
],
);
-test_sending(
- sietima => $s,
- mail => { cc => 'one@users.example.com' },
- to => ['two@users.example.com'],
-);
+subtest 'in cc' => sub {
+ 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'],
-);
+subtest 'in to' => sub {
+ test_sending(
+ sietima => $s,
+ mail => { to => $s->return_path . ' one@users.example.com' },
+ to => ['two@users.example.com'],
+ );
+};
done_testing;
diff --git a/t/tests/sietima/role/debounce.t b/t/tests/sietima/role/debounce.t
index 698cd36..903427b 100644
--- a/t/tests/sietima/role/debounce.t
+++ b/t/tests/sietima/role/debounce.t
@@ -13,33 +13,28 @@ my $s = make_sietima(
],
);
-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',
-);
+subtest 'header should be added' => sub {
+ test_sending(
+ sietima => $s,
+ mails => [
+ object {
+ call [ header_str => 'X-Been-There' ] =>
+ match qr{\b\Q$return_path\E\b};
+ },
+ ],
+ );
+};
-test_sending(
- sietima => $s,
- mail => {
- headers => { 'x-been-there' => $return_path },
- },
- to => [],
-);
+subtest 'header should inhibit sending' => sub {
+ test_sending(
+ sietima => $s,
+ mail => {
+ headers => { 'x-been-there' => $return_path },
+ },
+ to => [],
+ );
+};
done_testing;
diff --git a/t/tests/sietima/role/subject-tag.t b/t/tests/sietima/role/subject-tag.t
index 6dc579a..490f1a3 100644
--- a/t/tests/sietima/role/subject-tag.t
+++ b/t/tests/sietima/role/subject-tag.t
@@ -17,45 +17,28 @@ my $s = make_sietima(
subtest 'adding tag' => sub {
test_sending(
sietima => $s,
- );
-
- is(
- [ transport->deliveries ],
- array {
- item hash {
- field email => object {
- call [cast=>'Email::MIME'] => object {
- call [ header_str => 'Subject' ] =>
- '[foo] Test Message';
- };
- };
- };
- },
- 'subject tag should be added to all messages',
+ mails => [
+ object {
+ call [ header_str => 'Subject' ] =>
+ '[foo] Test Message';
+ },
+ ],
);
};
subtest 'tag already there' => sub {
+ my $subject = "[foo] \N{HEAVY BLACK HEART} test";
test_sending(
sietima => $s,
mail => {
- subject => my $subject = "[foo] \N{HEAVY BLACK HEART} test",
- },
- );
-
- is(
- [ transport->deliveries ],
- array {
- item hash {
- field email => object {
- call [cast=>'Email::MIME'] => object {
- call [ header_str => 'Subject' ] =>
- $subject;
- };
- };
- };
+ subject => $subject,
},
- 'subject tag should not be duplicated',
+ mails => [
+ object {
+ call [ header_str => 'Subject' ] =>
+ $subject;
+ },
+ ],
);
};
diff --git a/t/tests/sietima/role/subscriberonly/moderate.t b/t/tests/sietima/role/subscriberonly/moderate.t
index 6564b13..b76a01a 100644
--- a/t/tests/sietima/role/subscriberonly/moderate.t
+++ b/t/tests/sietima/role/subscriberonly/moderate.t
@@ -37,34 +37,22 @@ subtest 'from non-subscriber' => sub {
test_sending(
sietima => $s,
mail => { from=>'someone@users.example.com' },
- to => [$admin],
- );
-
-
- my @deliveries = transport->deliveries;
- is(
- \@deliveries,
- [
- hash {
- field email => object {
- call [cast=>'Email::MIME'] => object {
- call [header_str => 'subject'] => match qr{\bheld for moderation\b};
- call_list parts => [
- object {
- call body => match qr{Use id \S+ to refer to it};
- },
- object {
- call sub {Email::MIME->new(shift->body)} => object {
- call [header_str => 'subject'] => 'Test Message';
- };
- },
- ];
- };
- };
+ mails => [{
+ o => object {
+ call [header_str => 'subject'] => match qr{\bheld for moderation\b};
+ call_list parts => [
+ object {
+ call body => match qr{Use id \S+ to refer to it};
+ },
+ object {
+ call sub {Email::MIME->new(shift->body)} => object {
+ call [header_str => 'subject'] => 'Test Message';
+ };
+ },
+ ];
},
- ],
- 'the original mail should be attached',
- np @deliveries,
+ to => [$admin],
+ }],
);
is(