aboutsummaryrefslogtreecommitdiffstats
path: root/t/001-creates-a-new-alias-for-a-contact-with-an-existing-name.t
diff options
context:
space:
mode:
Diffstat (limited to 't/001-creates-a-new-alias-for-a-contact-with-an-existing-name.t')
-rw-r--r--t/001-creates-a-new-alias-for-a-contact-with-an-existing-name.t48
1 files changed, 48 insertions, 0 deletions
diff --git a/t/001-creates-a-new-alias-for-a-contact-with-an-existing-name.t b/t/001-creates-a-new-alias-for-a-contact-with-an-existing-name.t
new file mode 100644
index 0000000..2ab2fa3
--- /dev/null
+++ b/t/001-creates-a-new-alias-for-a-contact-with-an-existing-name.t
@@ -0,0 +1,48 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use feature qw(say);
+
+# Append test alias to alises file
+open(my $fh, '>>', './testaliases') or die;
+say $fh 'alias paris-numa NUMA Paris <communique@numa.co>';
+close $fh;
+
+
+my $output = `cat ./testdata/email | ./target/debug/alias-auto-add`;
+ok !$?;
+
+# Check that the program outputs the full email coming from STDIN
+{
+ open(my $fh, '<', './testdata/email') or die;
+ local $/ = undef;
+ my $email = <$fh>;
+
+ is $output, $email;
+
+ close $fh;
+}
+
+# Check that the aliases file includes an alias for the address from the input email
+{
+ open(my $fh, '<', './testaliases') or die;
+
+ my $last_line;
+ while (my $line = readline $fh) {
+ $last_line = $line;
+ }
+
+ is $last_line, 'alias paris-numa-2 NUMA Paris <communication@numa.co>' . "\n";
+
+ close $fh;
+}
+
+
+# Teardown
+
+
+done_testing;