Unit Tests

- Removed useless setup/teardown tests, improving the signal to noise ratio.
This commit is contained in:
Paul Beckingham 2014-06-01 10:02:53 -04:00
parent eaffa392f9
commit 307ea1c857
9 changed files with 10 additions and 70 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, '>', 'rc.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"foo=bar\n"; "foo=bar\n";
close $fh; close $fh;
ok (-r 'rc.rc', 'Created rc.rc');
} }
my $output = qx{../src/task rc:rc.rc show 2>&1}; my $output = qx{../src/task rc:rc.rc show 2>&1};
@ -48,8 +47,7 @@ like ($output, qr/^.*foo.+bar.*$/m, 'unmodified');
$output = qx{../src/task rc:rc.rc rc.foo:baz show 2>&1}; $output = qx{../src/task rc:rc.rc rc.foo:baz show 2>&1};
like ($output, qr/^.*foo.*baz.*$/m, 'overridden'); like ($output, qr/^.*foo.*baz.*$/m, 'overridden');
# Cleanup.
unlink 'rc.rc'; unlink 'rc.rc';
ok (!-r 'rc.rc', 'Removed rc.rc');
exit 0; exit 0;

View file

@ -28,7 +28,7 @@
use strict; use strict;
use warnings; use warnings;
use File::Path; use File::Path;
use Test::More tests => 15; use Test::More tests => 13;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -87,10 +87,6 @@ $output = qx{../src/task rc:foo.rc show 2>&1};
like ($output, qr/^must_be_unique\s+one two three/ms, 'config allows multi-word unquoted values'); like ($output, qr/^must_be_unique\s+one two three/ms, 'config allows multi-word unquoted values');
rmtree 'foo', 0, 0; rmtree 'foo', 0, 0;
ok (!-r 'foo', 'Removed foo');
unlink 'foo.rc'; unlink 'foo.rc';
ok (!-r 'foo.rc', 'Removed foo.rc');
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'};
@ -42,7 +42,6 @@ if (open my $fh, '>', 'roundtrip.rc')
"defaultwidth=100\n", "defaultwidth=100\n",
"dateformat=m/d/Y\n"; "dateformat=m/d/Y\n";
close $fh; close $fh;
ok (-r 'roundtrip.rc', 'Created roundtrip.rc');
} }
# Add two tasks. # Add two tasks.
@ -76,13 +75,5 @@ like ($output, qr/^$/, 'JSON files roundtrip1.json and roundtrip2.json identical
# Cleanup. # Cleanup.
unlink qw(roundtrip1.json roundtrip2.json pending.data completed.data undo.data backlog.data roundtrip.rc); unlink qw(roundtrip1.json roundtrip2.json pending.data completed.data undo.data backlog.data roundtrip.rc);
ok (! -r 'roundtrip1.json' &&
! -r 'roundtrip2.json' &&
! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'roundtrip.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 26; use Test::More tests => 24;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -40,7 +40,6 @@ if (open my $fh, '>', 'seq.rc')
"confirmation=off\n", "confirmation=off\n",
"dateformat.annotation=m/d/Y\n"; "dateformat.annotation=m/d/Y\n";
close $fh; close $fh;
ok (-r 'seq.rc', 'Created seq.rc');
} }
# Test sequences in done/undo # Test sequences in done/undo
@ -123,11 +122,5 @@ like ($output, qr/\d+\/\d+\/\d+ note/, 'sequence 2 annotate');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data seq.rc); unlink qw(pending.data completed.data undo.data backlog.data seq.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'seq.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'};
@ -42,7 +42,6 @@ if (open my $fh, '>', 'shadow.rc')
"shadow.command=rc:shadow.rc stats\n", "shadow.command=rc:shadow.rc stats\n",
"shadow.notify=on\n"; "shadow.notify=on\n";
close $fh; close $fh;
ok (-r 'shadow.rc', 'Created shadow.rc');
} }
my $output = qx{../src/task rc:shadow.rc add one 2>&1 >/dev/null}; my $output = qx{../src/task rc:shadow.rc add one 2>&1 >/dev/null};
@ -74,13 +73,6 @@ like ($file, qr/Projects\s+0\n/, 'Projects 0');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data shadow.txt shadow.rc); unlink qw(pending.data completed.data undo.data backlog.data shadow.txt shadow.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'shadow.txt' &&
! -r 'shadow.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'};
@ -41,7 +41,6 @@ if (open my $fh, '>', 'shell.rc')
"defaultwidth=0\n", "defaultwidth=0\n",
"default.command=ls\n"; "default.command=ls\n";
close $fh; close $fh;
ok (-r 'shell.rc', 'Created shell.rc');
} }
# Test the prompt. # Test the prompt.
@ -58,11 +57,5 @@ ok (!-r 'shell.rc', 'Removed shell.rc');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data shell.rc); unlink qw(pending.data completed.data undo.data backlog.data shell.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'shell.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 100; use Test::More tests => 98;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'sorting.rc')
{ {
print $fh "data.location=.\n"; print $fh "data.location=.\n";
close $fh; close $fh;
ok (-r 'sorting.rc', 'Created sorting.rc');
} }
# Test assorted sort orders. # Test assorted sort orders.
@ -181,11 +180,5 @@ for my $sort (sort keys %tests)
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data sorting.rc); unlink qw(pending.data completed.data undo.data backlog.data sorting.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'sorting.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'};
@ -45,7 +45,6 @@ if (open my $fh, '>', 'special.rc')
"nag=NAG\n", "nag=NAG\n",
"_forcecolor=1\n"; "_forcecolor=1\n";
close $fh; close $fh;
ok (-r 'special.rc', 'Created special.rc');
} }
# Prove that +nocolor suppresses all color for a task. # Prove that +nocolor suppresses all color for a task.
@ -63,11 +62,5 @@ unlike ($output, qr/NAG/, '+nonag suppressed nagging for task 2');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data special.rc); unlink qw(pending.data completed.data undo.data backlog.data special.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'special.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 17; use Test::More tests => 15;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'start.rc')
{ {
print $fh "data.location=.\n"; print $fh "data.location=.\n";
close $fh; close $fh;
ok (-r 'start.rc', 'Created start.rc');
} }
# Test the add/start/stop commands. # Test the add/start/stop commands.
@ -106,13 +105,5 @@ like ($output, qr/Nu.+stannar.+vi/ms, 'one stopped and annotated with custom des
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data start.rc start2.rc start3.rc); unlink qw(pending.data completed.data undo.data backlog.data start.rc start2.rc start3.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'start.rc' &&
! -r 'start2.rc' &&
! -r 'start3.rc', 'Cleanup');
exit 0; exit 0;