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.t14
1 files changed, 11 insertions, 3 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
index 2ab2fa3..26e8119 100644
--- 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
@@ -4,16 +4,23 @@ use strict;
use warnings;
use Test::More;
+use File::Copy qw(copy);
use feature qw(say);
+my $tmp_file = "./testdata/tmp";
+
+# Setup: make a temporary alias file
+copy("./testdata/aliases", $tmp_file);
+
+
# Append test alias to alises file
-open(my $fh, '>>', './testaliases') or die;
+open(my $fh, '>>', $tmp_file) or die;
say $fh 'alias paris-numa NUMA Paris <communique@numa.co>';
close $fh;
-my $output = `cat ./testdata/email | ./target/debug/alias-auto-add`;
+my $output = `cat ./testdata/email | ./target/debug/alias-auto-add $tmp_file`;
ok !$?;
# Check that the program outputs the full email coming from STDIN
@@ -29,7 +36,7 @@ ok !$?;
# Check that the aliases file includes an alias for the address from the input email
{
- open(my $fh, '<', './testaliases') or die;
+ open(my $fh, '<', $tmp_file) or die;
my $last_line;
while (my $line = readline $fh) {
@@ -43,6 +50,7 @@ ok !$?;
# Teardown
+unlink $tmp_file;
done_testing;