Unit Tests

- Upgraded to use the new template.
This commit is contained in:
Paul Beckingham 2014-08-24 21:38:00 -04:00
parent 9f934925c5
commit 743d4dd155

View file

@ -33,8 +33,12 @@ use Test::More tests => 12;
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, '>', 'bug.rc') if (open my $fh, '>', $rc)
{ {
print $fh "data.location=.\n"; print $fh "data.location=.\n";
close $fh; close $fh;
@ -43,34 +47,34 @@ if (open my $fh, '>', 'bug.rc')
# Bug 956 - 'task ids' prints the header, which prevents using the command in # Bug 956 - 'task ids' prints the header, which prevents using the command in
# external script (it applies also for 'uuids' and helper subcommands). # external script (it applies also for 'uuids' and helper subcommands).
qx{../src/task rc:bug.rc add test 2>&1}; qx{../src/task rc:$rc add test 2>&1};
# Solution 1: rc.verbose=nothing # Solution 1: rc.verbose=nothing
my $output = qx{TASKRC=bug.rc ../src/task rc:bug.rc rc.verbose=nothing ids 2>&1}; my $output = qx{TASKRC=$rc ../src/task rc:$rc rc.verbose=nothing ids 2>&1};
like ($output, qr/^1$/m, 'ID 1 shown'); like ($output, qr/^1$/m, "$ut: ID 1 shown");
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "ids" (rc.verbose=nothing)'); unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with 'ids' (rc.verbose=nothing)");
$output = qx{TASKRC=bug.rc ../src/task rc.verbose=nothing uuids 2>&1}; $output = qx{TASKRC=$rc ../src/task rc.verbose=nothing uuids 2>&1};
like ($output, qr/^[0-9a-f-]*$/m, 'UUID shown'); like ($output, qr/^[0-9a-f-]*$/m, "$ut: UUID shown");
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "uuids" (rc.verbose=nothing)'); unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with 'uuids' (rc.verbose=nothing)");
$output = qx{TASKRC=bug.rc ../src/task rc.verbose=nothing uuids 2>&1}; $output = qx{TASKRC=$rc ../src/task rc.verbose=nothing uuids 2>&1};
like ($output, qr/^[0-9a-f-]*$/m, 'UUID shown'); like ($output, qr/^[0-9a-f-]*$/m, "$ut: UUID shown");
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "uuids" (rc.verbose=nothing)'); unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with 'uuids' (rc.verbose=nothing)");
# Solution 2: task ... 2>/dev/null # Solution 2: task ... 2>/dev/null
$output = qx{TASKRC=bug.rc ../src/task rc:bug.rc ids 2>/dev/null}; $output = qx{TASKRC=$rc ../src/task rc:$rc ids 2>/dev/null};
like ($output, qr/^1$/m, 'ID 1 shown'); like ($output, qr/^1$/m, "$ut: ID 1 shown");
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "ids" (2>/dev/null)'); unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with 'ids' (2>/dev/null)");
$output = qx{TASKRC=bug.rc ../src/task _ids 2>/dev/null}; $output = qx{TASKRC=$rc ../src/task _ids 2>/dev/null};
like ($output, qr/^[0-9a-f-]*$/m, 'UUID shown'); like ($output, qr/^[0-9a-f-]*$/m, "$ut: UUID shown");
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "_ids" (2>/dev/null)'); unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with '_ids' (2>/dev/null)");
$output = qx{TASKRC=bug.rc ../src/task _ids 2>/dev/null}; $output = qx{TASKRC=$rc ../src/task _ids 2>/dev/null};
like ($output, qr/^[0-9a-f-]*$/m, 'UUID shown'); like ($output, qr/^[0-9a-f-]*$/m, "$ut: UUID shown");
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "_ids" (2>/dev/null)'); unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with '_ids' (2>/dev/null)");
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc); unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0; exit 0;