Unit Tests

- Minor bug fixes.
This commit is contained in:
Paul Beckingham 2011-09-05 01:48:25 -04:00
parent e2d0126415
commit d1bc46c355
4 changed files with 34 additions and 54 deletions

View file

@ -28,15 +28,15 @@
use strict;
use warnings;
use Test::More tests => 10;
use Test::More tests => 5;
# Create the rc file.
if (open my $fh, '>', 'bug_concat.rc')
if (open my $fh, '>', 'bug.rc')
{
print $fh "data.location=.\n",
"confirmation=no\n";
close $fh;
ok (-r 'bug_concat.rc', 'Created bug_concat.rc');
ok (-r 'bug.rc', 'Created bug.rc');
}
# When a task is modified like this:
@ -47,12 +47,12 @@ if (open my $fh, '>', 'bug_concat.rc')
#
# Thisisanewdescription
qx{../src/task rc:bug_concat.rc add This is the original text};
my $output = qx{../src/task rc:bug_concat.rc info 1};
qx{../src/task rc:bug.rc add This is the original text};
my $output = qx{../src/task rc:bug.rc info 1};
like ($output, qr/Description\s+This is the original text/, 'original correct');
qx{../src/task rc:bug_concat.rc 1 modify This is the modified text};
$output = qx{../src/task rc:bug_concat.rc info 1};
qx{../src/task rc:bug.rc 1 modify This is the modified text};
$output = qx{../src/task rc:bug.rc info 1};
like ($output, qr/Description\s+This is the modified text\n/, 'modified correct');
# When a task is added like this:
@ -63,28 +63,18 @@ like ($output, qr/Description\s+This is the modified text\n/, 'modified correct'
#
# aaabbb:ccc ddd
qx{../src/task rc:bug_concat.rc add aaa bbb:ccc ddd};
$output = qx{../src/task rc:bug_concat.rc info 2};
qx{../src/task rc:bug.rc add aaa bbb:ccc ddd};
$output = qx{../src/task rc:bug.rc info 2};
like ($output, qr/Description\s+aaa bbb:ccc ddd\n/, 'properly concatenated');
# Cleanup.
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data');
unlink 'completed.data';
ok (!-r 'completed.data', 'Removed completed.data');
unlink 'undo.data';
ok (!-r 'undo.data', 'Removed undo.data');
unlink 'backlog.data';
ok (!-r 'backlog.data', 'Removed backlog.data');
unlink 'synch.key';
ok (!-r 'synch.key', 'Removed synch.key');
unlink 'bug_concat.rc';
ok (!-r 'bug_concat.rc', 'Removed bug_concat.rc');
unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'synch_key.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

View file

@ -28,7 +28,7 @@
use strict;
use warnings;
use Test::More tests => 9;
use Test::More tests => 4;
# Create the rc file.
if (open my $fh, '>', 'color.rc')
@ -51,23 +51,13 @@ like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none');
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.blocked');
# Cleanup.
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data');
unlink 'completed.data';
ok (!-r 'completed.data', 'Removed completed.data');
unlink 'backlog.data';
ok (!-r 'backlog.data', 'Removed backlog.data');
unlink 'synch.key';
ok (!-r 'synch.key', 'Removed synch.key');
unlink 'undo.data';
ok (!-r 'undo.data', 'Removed undo.data');
unlink 'color.rc';
ok (!-r 'color.rc', 'Removed color.rc');
unlink qw(pending.data completed.data undo.data backlog.data synch.key color.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'synch_key.data' &&
! -r 'color.rc', 'Cleanup');
exit 0;

View file

@ -36,13 +36,13 @@ use constant false => 0;
use constant true => 1;
# Create data locations
mkdir("data1", 0755);
ok(-e 'data1', "Created directory data1");
mkdir("data2", 0755);
ok(-e 'data2', "Created directory data2");
mkdir("data3", 0755);
ok(-e 'data3', "Created directory data3");
mkdir("data1", 0755);
mkdir("data2", 0755);
mkdir("data3", 0755);
mkdir('backup', 0755);
ok(-e 'data1', "Created directory data1");
ok(-e 'data2', "Created directory data2");
ok(-e 'data3', "Created directory data3");
ok(-e 'backup', "Created directory backup");
# Create the rc files.

View file

@ -89,9 +89,9 @@ sleep 1;
qx{../src/task rc:local.rc add right_completed};
sleep 1;
copy ("local/undo.data", "remote/undo.data") or fail ("copy local/undo.data to remote/undo.data");
copy ("local/pending.data", "remote/pending.data") or fail ("copy local/undo.data to remote/undo.data");
copy ("local/completed.data", "remote/completed.data") or fail ("copy local/undo.data to remote/undo.data");
copy ("local/undo.data", "remote/undo.data");
copy ("local/pending.data", "remote/pending.data");
copy ("local/completed.data", "remote/completed.data");
# make local modifications
qx{../src/task rc:local.rc add left_added}; #left_added
@ -137,7 +137,7 @@ sleep 1;
qx{../src/task rc:remote.rc 4 modify +gym}; # right_newer
# merge remote into local
copy ("local/undo.data", "local/undo.save") or fail ("copy local/undo.data to local/undo.save");
copy ("local/undo.data", "local/undo.save");
my $output_l = qx{../src/task rc:local.rc merge remote/};
#check output