Unit Tests

- Updated to use the new template.
This commit is contained in:
Paul Beckingham 2014-08-24 15:57:15 -04:00
parent ba72377209
commit ce7f6b6492

View file

@ -33,21 +33,25 @@ use Test::More tests => 2;
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'}; delete $ENV{'TASKRC'};
use File::Basename;
my $ut = basename ($0);
my $rc = $ut . '.rc';
# Create the rc file. # Create the rc file.
if (open my $fh, '>', 'exit.rc') if (open my $fh, '>', $rc)
{ {
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=no\n"; "confirmation=no\n";
close $fh; close $fh;
} }
qx{../src/task rc:exit.rc add foo 2>&1}; qx{../src/task rc:$rc add foo 2>&1};
my $exit_good = system ('../src/task rc:exit.rc ls /foo/ >/dev/null 2>&1') >> 8; my $exit_good = system ("../src/task rc:$rc ls /foo/ >/dev/null 2>&1") >> 8;
is ($exit_good, 0, 'task returns 0 on success'); is ($exit_good, 0, "$ut: task returns 0 on success");
my $exit_bad = system ('../src/task rc:exit.rc ls /bar/ >/dev/null 2>&1') >> 8; my $exit_bad = system ("../src/task rc:$rc ls /bar/ >/dev/null 2>&1") >> 8;
isnt ($exit_bad, 0, 'task returns non-zero on failure'); isnt ($exit_bad, 0, "$ut: task returns non-zero on failure");
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data exit.rc); unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0; exit 0;