LP#1694696: add some unit tests for A/T helpers
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 20 Jun 2017 18:56:43 +0000 (14:56 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 20 Jun 2017 19:01:16 +0000 (15:01 -0400)
In particular, start with get_sms_gateway_email().

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/live_t/23-action-trigger-templates.t [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/live_t/23-action-trigger-templates.t b/Open-ILS/src/perlmods/live_t/23-action-trigger-templates.t
new file mode 100644 (file)
index 0000000..cd71d82
--- /dev/null
@@ -0,0 +1,37 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+use OpenILS::Utils::TestUtils;
+use OpenILS::Const qw(:const);
+
+my $script = OpenILS::Utils::TestUtils->new();
+$script->bootstrap;
+
+use OpenILS::Application::Trigger::Reactor;
+my $r = "OpenILS::Application::Trigger::Reactor";
+
+my $env = {
+    carrier  => 1,
+    number   => '',
+    template => '[%- helpers.get_sms_gateway_email(carrier, number) -%]',
+};
+my $addr = $r->run_TT($env, 1);
+is($addr, '', 'helpers.get_sms_gateway_email: no number means no SMS gateway address');
+
+$env = {
+    carrier  => 1,
+    number   => '9015551212',
+    template => '[%- helpers.get_sms_gateway_email(carrier, number) -%]',
+};
+$addr = $r->run_TT($env, 1);
+is($addr, 'opensrf+9015551212@localhost', 'helpers.get_sms_gateway_email: get back a SMS gateway address');
+
+$env = {
+    carrier  => '',
+    number   => '9015551212',
+    template => '[%- helpers.get_sms_gateway_email(carrier, number) -%]',
+};
+$addr = $r->run_TT($env, 1);
+is($addr, '', 'helpers.get_sms_gateway_email: no carrier means no SMS gateway address');