Unit Tests

- Tests now conform to template.
This commit is contained in:
Paul Beckingham 2014-06-15 09:30:46 -04:00
parent 784b14c69a
commit 5b2505f6da

View file

@ -33,28 +33,32 @@ use Test::More tests => 2;
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
use File::Basename;
my $ut = basename ($0);
my $rc = $ut . '.rc';
# Create the rc file.
if (open my $fh, '>', 'uda.rc')
if (open my $fh, '>', $rc)
{
print $fh "data.location=.\n",
"confirmation=off\n",
"uda.extra.type=string\n",
"uda.extra.label=Extra\n",
"report.uda.description=UDA Test\n",
"report.uda.columns=id,extra,description\n",
"report.uda.sort=extra,description\n",
"report.uda.labels=ID,Extra,Description\n";
"report.uuu.description=UDA Test\n",
"report.uuu.columns=id,extra,description\n",
"report.uuu.sort=extra,description\n",
"report.uuu.labels=ID,Extra,Description\n";
close $fh;
}
# Add tasks with and without the UDA.
qx{../src/task rc:uda.rc add with extra:"one two" 2>&1};
qx{../src/task rc:uda.rc add without 2>&1};
my $output = qx{../src/task rc:uda.rc uda 2>&1};
like ($output, qr/1\s+one two\s+with/, 'UDA string stored');
like ($output, qr/2\s+without/, 'UDA string blank');
qx{../src/task rc:$rc add with extra:"one two" 2>&1};
qx{../src/task rc:$rc add without 2>&1};
my $output = qx{../src/task rc:$rc uuu 2>&1};
like ($output, qr/1\s+one two\s+with/, "$ut: UDA string stored");
like ($output, qr/2\s+without/, "$ut: UDA string blank");
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data uda.rc);
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0;