aboutsummaryrefslogtreecommitdiffstats
path: root/t/email
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2017-11-03 16:13:59 +0100
committerMarius Halden <marius.h@lden.org>2017-11-03 16:13:59 +0100
commit42d874db498d0fabae92d0c87acf99054d92391b (patch)
treed0cf5afdee3d244c4e5da6fe1ab9acba620634df /t/email
parent19a7c5dda85a47a68040c742791e9cd9d3e52be6 (diff)
parentdc7613329c275cd158fdde8faf1c0e301f5b7202 (diff)
Merge tag 'v2.2' into fiksgatami-dev
Diffstat (limited to 't/email')
-rw-r--r--t/email/sender.t36
1 files changed, 36 insertions, 0 deletions
diff --git a/t/email/sender.t b/t/email/sender.t
new file mode 100644
index 000000000..49310db83
--- /dev/null
+++ b/t/email/sender.t
@@ -0,0 +1,36 @@
+use FixMyStreet::Test;
+use FixMyStreet::Email::Sender;
+use Test::Exception;
+
+# Specifically testing live email sending errors
+FixMyStreet->test_mode(0);
+
+subtest 'SMTP settings' => sub {
+ FixMyStreet::override_config {
+ SMTP_SMARTHOST => 'localhost',
+ SMTP_TYPE => 'bad',
+ }, sub {
+ throws_ok { FixMyStreet::Email::Sender->send('test') }
+ qr/Bad SMTP_TYPE config: is bad, should be tls, ssl, or blank/, 'Bad SMTP_TYPE throws';
+ };
+
+ FixMyStreet::override_config {
+ SMTP_SMARTHOST => 'localhost',
+ SMTP_TYPE => 'TLS',
+ }, sub {
+ throws_ok { FixMyStreet::Email::Sender->send('test') }
+ qr/no recipients/, 'Upper case SMTP_TYPE passes, no recipients throws';
+ };
+};
+
+subtest 'sendmail default' => sub {
+ FixMyStreet::override_config {
+ SMTP_SMARTHOST => '',
+ }, sub {
+ FixMyStreet::Email::Sender->reset_default_transport;
+ throws_ok { FixMyStreet::Email::Sender->send('test') }
+ qr/no recipients|couldn't find a sendmail/, 'Sendmail throws some form of error';
+ };
+};
+
+done_testing();