Unit Tests

- Removed useless setup/teardown tests, improving the signal to noise ratio.
This commit is contained in:
Paul Beckingham 2014-06-01 10:34:24 -04:00
parent e1d6b84dcd
commit e70ec9f967
10 changed files with 20 additions and 90 deletions

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 4;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc')
print $fh "data.location=.\n",
"confirmation=off\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug #605 - project count zero bug?
@ -58,11 +57,5 @@ like ($output, qr/is 100\% complete/ms, 'Empty project correctly reported as bei
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 3;
use Test::More tests => 1;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -40,13 +40,12 @@ if (open my $fh, '>', 'bug.rc')
"confirmation=no\n",
"dateformat=a b D Y\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug 628: task wait: with non-standard dateformat bug
# Setup: Add a task
qx{../src/task rc:bug.rc add wait:\\"Wed Jan 01 2020\\" A buggy task 2>&1};
qx{../src/task rc:bug.rc add wait:"Wed Jan 01 2030" A buggy task 2>&1};
# Result: Immediately delete the created task
my $output = qx{../src/task rc:bug.rc waiting 2>&1};
@ -54,11 +53,5 @@ like ($output, qr/Jan 01 2020/ms, 'a b D Y dateformat correctly parsed.');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 4;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc')
print $fh "data.location=.\n",
"confirmation=no\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug 634: confirmation=off not honored by undo
@ -54,11 +53,5 @@ unlike ($output, qr/Are you sure/ms, 'Undo honours confirmation=off.');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 3;
use Test::More tests => 1;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc')
print $fh "data.location=.\n",
"confirmation=no\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug 635: /OLD/NEW/g is broken?
@ -56,11 +55,5 @@ like ($output, qr/Pay the rent on the 31st/ms, 'Global replace performed correct
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 4;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc')
print $fh "data.location=.\n",
"confirmation=no\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug 649: 1.9.4 commit ae4e286 - Recurring tasks can't be immediately
@ -55,11 +54,5 @@ unlike ($output, qr/Completed 1/ms, 'New recurring task cannot be immediately co
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 4;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc')
print $fh "data.location=.\n",
"confirmation=no\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug 656: Recurring task continually spawns new tasks
@ -59,11 +58,5 @@ unlike ($output, qr/^\s3\s*Second recurring task\s*$/ms, 'Extra task detected.')
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 3;
use Test::More tests => 1;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'bug.rc')
{
print $fh "data.location=.\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug 674: ID numbers change between reports when marking tasks as done
@ -57,11 +56,5 @@ like ($output, qr/Two/ms, 'IDs correctly remain unchanged after done');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 5;
use Test::More tests => 3;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'bug.rc')
{
print $fh "data.location=.\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug 694: Potential bug for "due" and "annotate"
@ -55,11 +54,5 @@ like ($output, qr/Due/, 'found Due');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 10;
use Test::More tests => 8;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc')
print $fh "data.location=.\n";
print $fh "confirmation=no\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug 703: /from/t/g fails to make all changes to annotations
@ -65,11 +64,5 @@ like ($output, qr/AnnotatIon three/, 'new annotation three');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -27,7 +27,7 @@
use strict;
use warnings;
use Test::More tests => 6;
use Test::More tests => 4;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
@ -40,25 +40,24 @@ if (open my $fh, '>', 'bug.rc')
print $fh "bulk=100\n";
print $fh "confirmation=no\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug 708: Bad Math in Project is % Complete
# Setup: Add a few tasks
qx{../src/task rc:bug.rc add One pro:p1 2>&1};
qx{../src/task rc:bug.rc add Two pro:p1 2>&1};
qx{../src/task rc:bug.rc add One pro:p1 2>&1};
qx{../src/task rc:bug.rc add Two pro:p1 2>&1};
qx{../src/task rc:bug.rc add Three pro:p1 2>&1};
qx{../src/task rc:bug.rc add Four pro:p1 2>&1};
qx{../src/task rc:bug.rc add Five pro:p1 2>&1};
qx{../src/task rc:bug.rc add Six pro:p1 2>&1};
qx{../src/task rc:bug.rc add Four pro:p1 2>&1};
qx{../src/task rc:bug.rc add Five pro:p1 2>&1};
qx{../src/task rc:bug.rc add Six pro:p1 2>&1};
qx{../src/task rc:bug.rc add Seven pro:p1 2>&1};
qx{../src/task rc:bug.rc add Eight pro:p1 2>&1};
qx{../src/task rc:bug.rc add Nine pro:p1 2>&1};
qx{../src/task rc:bug.rc add Ten pro:p1 2>&1};
qx{../src/task rc:bug.rc add Nine pro:p1 2>&1};
qx{../src/task rc:bug.rc add Ten pro:p1 2>&1};
# Complete three tasks and ensure pending and done counts are updated correctly.
my $output = qx{../src/task rc:bug.rc 1-3 do 2>&1 >/dev/null};
my $output = qx{../src/task rc:bug.rc 1-3 done 2>&1 >/dev/null};
like ($output, qr/Project 'p1' is 30% complete \(7 of 10 tasks remaining\)\./ms, 'Project counts correct for a multiple done');
# Change three projects and ensure pending and done counts are updated correctly.
@ -67,16 +66,10 @@ like ($output, qr/Project 'p1' is 42% complete \(4 of 7 tasks remaining\)\./ms
like ($output, qr/Project 'p2' is 0% complete \(3 of 3 tasks remaining\)\./ms, 'Project counts correct for a multiple project reassignment part b');
# Delete three tasks and ensure pending and done counts are updated correctly.
$output = qx{../src/task rc:bug.rc 7-9 del 2>&1 >/dev/null};
$output = qx{../src/task rc:bug.rc 7-9 delete 2>&1 >/dev/null};
like ($output, qr/Project 'p1' is 75% complete \(1 of 4 tasks remaining\)\./ms, 'Project counts correct for a multiple delete');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;