aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-04-22 22:22:23 -0400
committerTeddy Wing2016-04-22 22:22:23 -0400
commit0d3e1073e4a3f683b746a5248227c57004ba8cec (patch)
tree739f3c4d0fa881ea0a243992d249c9c43d0b7ae5
parentb9f6915d1e92f77c002f05a1371941dd3e3dcb95 (diff)
parentc4302101fd44747e33e0d3b311e659f9467e3e18 (diff)
downloadmutt-alias-auto-add-0d3e1073e4a3f683b746a5248227c57004ba8cec.tar.bz2
Merge branch 'integration-test'
-rw-r--r--Makefile2
-rw-r--r--t/001-creates-a-new-alias-for-a-contact-with-an-existing-name.t48
2 files changed, 50 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3204ff4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,2 @@
+test-integration:
+ prove -v
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;