Unit Tests

- Upgraded to user the new template.
- Removed code that detected EOM an skipped tests. This should no longer be
  needed with the ISO date support, where EOM is the true EOM.
This commit is contained in:
Paul Beckingham 2014-10-26 09:32:34 -04:00
parent 74526ee564
commit 822031bf0b

View file

@ -34,8 +34,12 @@ use Test::More tests => 5;
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, '>', 'count.rc')
if (open my $fh, '>', $rc)
{
print $fh "data.location=.\n",
"confirmation=off\n";
@ -43,46 +47,29 @@ if (open my $fh, '>', 'count.rc')
}
# Test the count command.
qx{../src/task rc:count.rc add one 2>&1};
qx{../src/task rc:count.rc log two 2>&1};
qx{../src/task rc:count.rc add three 2>&1};
qx{../src/task rc:count.rc 2 delete 2>&1};
qx{../src/task rc:count.rc add four wait:eom 2>&1};
qx{../src/task rc:$rc add one 2>&1};
qx{../src/task rc:$rc log two 2>&1};
qx{../src/task rc:$rc add three 2>&1};
qx{../src/task rc:$rc 2 delete 2>&1};
qx{../src/task rc:$rc add four wait:eom 2>&1};
qx{../src/task rc:$rc add five due:eom recur:monthly 2>&1};
TODO: {
my @today = localtime;
my @tomorrow = @today;
$tomorrow[3] += 1;
@tomorrow = localtime(mktime(@tomorrow));
local $TODO = 'can fail when today == eom' if $today[4] != $tomorrow[4];
my $output = qx{../src/task rc:$rc count 2>&1};
like ($output, qr/^5\n/ms, "$ut: count");
# TODO This fails when today == eom. For example, on 2013-04-30 at 8:00:00, the
# value for 'eom' is 2013-04-30 0:00:00, which is already past due, which
# means a second child task is generated. This would be fixed by 'eom'
# expanding to 2013-04-30 24:00:00, as per ISO-8601.
qx{../src/task rc:count.rc add five due:eom recur:monthly 2>&1};
$output = qx{../src/task rc:$rc count status:deleted rc.debug:1 2>&1};
like ($output, qr/^1\n/ms, "$ut: count status:deleted");
diag ("Problem: the next test fails at EOM");
my $output = qx{../src/task rc:count.rc count 2>&1};
like ($output, qr/^5\n/ms, 'count');
$output = qx{../src/task rc:$rc count e 2>&1};
like ($output, qr/^3\n/ms, "$ut: count e");
$output = qx{../src/task rc:count.rc count status:deleted rc.debug:1 2>&1};
like ($output, qr/^1\n/ms, 'count status:deleted');
$output = qx{../src/task rc:$rc count description.startswith:f 2>&1};
like ($output, qr/^2\n/ms, "$ut: count description.startswith:f");
diag ("Problem: the next test fails at EOM");
$output = qx{../src/task rc:count.rc count e 2>&1};
like ($output, qr/^3\n/ms, 'count e');
diag ("Problem: the next test fails at EOM");
$output = qx{../src/task rc:count.rc count description.startswith:f 2>&1};
like ($output, qr/^2\n/ms, 'count description.startswith:f');
diag ("Problem: the next test fails at EOM");
$output = qx{../src/task rc:count.rc count due.any: 2>&1};
like ($output, qr/^1\n/ms, 'count due.any:');
}
$output = qx{../src/task rc:$rc count due.any: 2>&1};
like ($output, qr/^1\n/ms, "$ut: count due.any:");
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data count.rc);
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0;