Unit Tests

- Removed useless setup/teardown tests, improving the signal to noise ratio.
This commit is contained in:
Paul Beckingham 2014-06-01 10:00:45 -04:00
parent 8eef295bea
commit eaffa392f9
8 changed files with 9 additions and 69 deletions

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 4; use Test::More tests => 2;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'iso.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"dateformat.info=m/d/Y\n"; "dateformat.info=m/d/Y\n";
close $fh; close $fh;
ok (-r 'iso.rc', 'Created iso.rc');
} }
# Test use of ISO date format, despite rc.dateformat. # Test use of ISO date format, despite rc.dateformat.
@ -48,17 +47,11 @@ my $output = qx{../src/task rc:iso.rc 1 info 2>&1};
like ($output, qr/Due\s+9\/1\/2011/, 'ISO format recognized.'); like ($output, qr/Due\s+9\/1\/2011/, 'ISO format recognized.');
# Test use of epoch date format, despite rc.dateformat. # Test use of epoch date format, despite rc.dateformat.
qx{../src/task rc:iso.rc add one due:1234524690 2>&1}; qx{../src/task rc:iso.rc add two due:1234524690 2>&1};
$output = qx{../src/task rc:iso.rc 2 info 2>&1}; $output = qx{../src/task rc:iso.rc 2 info 2>&1};
like ($output, qr/Due\s+2\/13\/2009/, 'Epoch format recognized.'); like ($output, qr/Due\s+2\/13\/2009/, 'Epoch format recognized.');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data iso.rc); unlink qw(pending.data completed.data undo.data backlog.data iso.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'iso.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 10; use Test::More tests => 6;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -41,7 +41,6 @@ if (open my $fh, '>', 'date1.rc')
"dateformat.info=YMD\n", "dateformat.info=YMD\n",
"dateformat.report=YMD\n"; "dateformat.report=YMD\n";
close $fh; close $fh;
ok (-r 'date1.rc', 'Created date1.rc');
} }
if (open my $fh, '>', 'date2.rc') if (open my $fh, '>', 'date2.rc')
@ -51,7 +50,6 @@ if (open my $fh, '>', 'date2.rc')
"dateformat.info=m/d/y\n", "dateformat.info=m/d/y\n",
"dateformat.report=m/d/y\n"; "dateformat.report=m/d/y\n";
close $fh; close $fh;
ok (-r 'date2.rc', 'Created date2.rc');
} }
if (open my $fh, '>', 'date3.rc') if (open my $fh, '>', 'date3.rc')
@ -63,7 +61,6 @@ if (open my $fh, '>', 'date3.rc')
"dateformat.info=A D B Y (wV)\n", "dateformat.info=A D B Y (wV)\n",
"dateformat.report=A D B Y (wV)\n"; "dateformat.report=A D B Y (wV)\n";
close $fh; close $fh;
ok (-r 'date3.rc', 'Created date3.rc');
} }
qx{../src/task rc:date1.rc add foo due:20091231 2>&1}; qx{../src/task rc:date1.rc add foo due:20091231 2>&1};
@ -88,13 +85,5 @@ like ($output, qr/08 Apr 2010 - Thu/, 'date format D b Y - a parsed');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data date1.rc date2.rc date3.rc); unlink qw(pending.data completed.data undo.data backlog.data date1.rc date2.rc date3.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'date1.rc' &&
! -r 'date2.rc' &&
! -r 'date3.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 27; use Test::More tests => 25;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -45,7 +45,6 @@ if (open my $fh, '>', 'denotate.rc')
"report.rrr.sort=id+\n", "report.rrr.sort=id+\n",
"dateformat=m/d/Y\n"; "dateformat=m/d/Y\n";
close $fh; close $fh;
ok (-r 'denotate.rc', 'Created denotate.rc');
} }
# Add four tasks, annotate one three times, one twice, one just once and one none. # Add four tasks, annotate one three times, one twice, one just once and one none.
@ -105,10 +104,4 @@ unlike ($output, qr/frog.+\d{1,2}\/\d{1,2}\/\d{4} Kermit and Miss Piggy/ms, 'Del
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data denotate.rc); unlink qw(pending.data completed.data undo.data backlog.data denotate.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'denotate.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 54; use Test::More tests => 52;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'oldest.rc')
{ {
print $fh "data.location=.\n"; print $fh "data.location=.\n";
close $fh; close $fh;
ok (-r 'oldest.rc', 'Created oldest.rc');
} }
# Add 11 tasks. Oldest should show 1-10, newest should show 2-11. # Add 11 tasks. Oldest should show 1-10, newest should show 2-11.
@ -132,11 +131,5 @@ like ($output, qr/ eleven/, 'newest: eleven');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data oldest.rc); unlink qw(pending.data completed.data undo.data backlog.data oldest.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'oldest.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 5; use Test::More tests => 3;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'due.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"due=4\n"; "due=4\n";
close $fh; close $fh;
ok (-r 'due.rc', 'Created due.rc');
} }
# Add an overdue task, a due task, and a regular task. The "overdue" report # Add an overdue task, a due task, and a regular task. The "overdue" report
@ -54,11 +53,5 @@ unlike ($output, qr/three/, 'overdue: task 3 does not show up');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data due.rc); unlink qw(pending.data completed.data undo.data backlog.data due.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'due.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 3; use Test::More tests => 1;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -43,7 +43,6 @@ if (open my $fh, '>', 'or.rc')
"report.zzz.sort=due+\n", "report.zzz.sort=due+\n",
"report.zzz.filter=status:pending rc.annotations:full\n"; "report.zzz.filter=status:pending rc.annotations:full\n";
close $fh; close $fh;
ok (-r 'or.rc', 'Created or.rc');
} }
# The zzz report is defined with an override in the filter that contradicts # The zzz report is defined with an override in the filter that contradicts
@ -55,11 +54,5 @@ like ($output, qr/ONE.+TWO/ms, 'filter override > rc setting');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data or.rc); unlink qw(pending.data completed.data undo.data backlog.data or.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'or.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 4; use Test::More tests => 2;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'prepend.rc')
{ {
print $fh "data.location=.\n"; print $fh "data.location=.\n";
close $fh; close $fh;
ok (-r 'prepend.rc', 'Created prepend.rc');
} }
# Add a task, then prepend more decsription. # Add a task, then prepend more decsription.
@ -53,11 +52,5 @@ unlike ($output, qr/Prepended 0 tasks/, 'blank prepend failed');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data prepend.rc); unlink qw(pending.data completed.data undo.data backlog.data prepend.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'prepend.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 18; use Test::More tests => 16;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'pro.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=off\n"; "confirmation=off\n";
close $fh; close $fh;
ok (-r 'pro.rc', 'Created pro.rc');
} }
# Test the project status numbers. # Test the project status numbers.
@ -156,11 +155,5 @@ like ($project_name_column, qr/^myProject\.\s*$/, '\'myProject.\' not indented')
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data pro.rc); unlink qw(pending.data completed.data undo.data backlog.data pro.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'pro.rc', 'Cleanup');
exit 0; exit 0;