mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit Tests
- The unit tests needed a little love after "undelete" went away, and "undo" changed. - Fixed a few tests that were broken.
This commit is contained in:
parent
367214c57a
commit
ef7c5dc4eb
9 changed files with 37 additions and 50 deletions
|
@ -28,7 +28,7 @@
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 15;
|
||||
use Test::More tests => 13;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'add.rc')
|
||||
|
@ -60,12 +60,6 @@ $output = qx{../task rc:add.rc info 1};
|
|||
like ($output, qr/ID\s+1\n/, 'add ID');
|
||||
like ($output, qr/Status\s+Deleted\n/, 'add Deleted');
|
||||
|
||||
# Test undelete.
|
||||
qx{../task rc:add.rc undelete 1};
|
||||
$output = qx{../task rc:add.rc info 1};
|
||||
like ($output, qr/ID\s+1\n/, 'add ID');
|
||||
like ($output, qr/Status\s+Pending\n/, 'add Pending');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
|
|
@ -43,7 +43,7 @@ if (open my $fh, '>', 'cal.rc')
|
|||
ok (-r 'cal.rc', 'Created cal.rc');
|
||||
}
|
||||
|
||||
(my $day,my $nmon,my $nyear) = (localtime)[3,4,5];
|
||||
my ($day, $nmon, $nyear) = (localtime)[3,4,5];
|
||||
my $nextmonth = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon+1) % 12];
|
||||
my $month = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon) % 12];
|
||||
my $prevmonth = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon-1) % 12];
|
||||
|
|
|
@ -33,7 +33,7 @@ Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (76);
|
||||
UnitTest t (78);
|
||||
|
||||
context.config.set ("report.foo.columns", "id");
|
||||
|
||||
|
@ -106,6 +106,14 @@ int main (int argc, char** argv)
|
|||
t.ok (cmd.isReadOnlyCommand (), "isReadOnlyCommand version");
|
||||
t.notok (cmd.isWriteCommand (), "not isWriteCommand version");
|
||||
|
||||
cmd.command = "_projects";
|
||||
t.ok (cmd.isReadOnlyCommand (), "not isReadOnlyCommand _projects");
|
||||
t.notok (cmd.isWriteCommand (), "isWriteCommand _projects");
|
||||
|
||||
cmd.command = "_tags";
|
||||
t.ok (cmd.isReadOnlyCommand (), "not isReadOnlyCommand _tags");
|
||||
t.notok (cmd.isWriteCommand (), "isWriteCommand _tags");
|
||||
|
||||
cmd.command = "add";
|
||||
t.notok (cmd.isReadOnlyCommand (), "not isReadOnlyCommand add");
|
||||
t.ok (cmd.isWriteCommand (), "isWriteCommand add");
|
||||
|
@ -146,10 +154,6 @@ int main (int argc, char** argv)
|
|||
t.notok (cmd.isReadOnlyCommand (), "not isReadOnlyCommand stop");
|
||||
t.ok (cmd.isWriteCommand (), "isWriteCommand stop");
|
||||
|
||||
cmd.command = "undelete";
|
||||
t.notok (cmd.isReadOnlyCommand (), "not isReadOnlyCommand undelete");
|
||||
t.ok (cmd.isWriteCommand (), "isWriteCommand undelete");
|
||||
|
||||
cmd.command = "undo";
|
||||
t.notok (cmd.isReadOnlyCommand (), "not isReadOnlyCommand undo");
|
||||
t.ok (cmd.isWriteCommand (), "isWriteCommand undo");
|
||||
|
|
|
@ -28,38 +28,35 @@
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 18;
|
||||
use Test::More tests => 17;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'undelete.rc')
|
||||
if (open my $fh, '>', 'delete.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"echo.command=no\n";
|
||||
close $fh;
|
||||
ok (-r 'undelete.rc', 'Created undelete.rc');
|
||||
ok (-r 'delete.rc', 'Created delete.rc');
|
||||
}
|
||||
|
||||
# Add a task, delete it, undelete it.
|
||||
my $output = qx{../task rc:undelete.rc add one; ../task rc:undelete.rc info 1};
|
||||
my $output = qx{../task rc:delete.rc add one; ../task rc:delete.rc info 1};
|
||||
ok (-r 'pending.data', 'pending.data created');
|
||||
like ($output, qr/Status\s+Pending\n/, 'Pending');
|
||||
|
||||
$output = qx{../task rc:undelete.rc delete 1; ../task rc:undelete.rc info 1};
|
||||
$output = qx{../task rc:delete.rc delete 1; ../task rc:delete.rc info 1};
|
||||
like ($output, qr/Status\s+Deleted\n/, 'Deleted');
|
||||
ok (-r 'completed.data', 'completed.data created');
|
||||
|
||||
$output = qx{../task rc:undelete.rc undelete 1; ../task rc:undelete.rc info 1};
|
||||
$output = qx{echo 'y' | ../task rc:delete.rc undo; ../task rc:delete.rc info 1};
|
||||
like ($output, qr/Status\s+Pending\n/, 'Pending');
|
||||
ok (-r 'completed.data', 'completed.data created');
|
||||
|
||||
$output = qx{../task rc:undelete.rc delete 1; ../task rc:undelete.rc list};
|
||||
$output = qx{../task rc:delete.rc delete 1; ../task rc:delete.rc list};
|
||||
like ($output, qr/No matches./, 'No matches');
|
||||
ok (-r 'completed.data', 'completed.data created');
|
||||
|
||||
$output = qx{../task rc:undelete.rc undelete 1};
|
||||
like ($output, qr/Task 1 not found/, 'Task 1 not found');
|
||||
|
||||
$output = qx{../task rc:undelete.rc info 1};
|
||||
$output = qx{../task rc:delete.rc info 1};
|
||||
like ($output, qr/Task 1 not found/, 'No matches');
|
||||
|
||||
# Cleanup.
|
||||
|
@ -75,8 +72,8 @@ ok (-r 'undo.data', 'Need to remove undo.data');
|
|||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'undelete.rc';
|
||||
ok (!-r 'undelete.rc', 'Removed undelete.rc');
|
||||
unlink 'delete.rc';
|
||||
ok (!-r 'delete.rc', 'Removed delete.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
|
|
|
@ -54,13 +54,7 @@ like ($output, qr/Imported 2 tasks successfully, with 0 errors./, 'no errors');
|
|||
|
||||
$output = qx{../task rc:import.rc list};
|
||||
like ($output, qr/1.+H.+this is a test/, 't1');
|
||||
diag ("---");
|
||||
diag ($output);
|
||||
diag ("---");
|
||||
like ($output, qr/2.+another task/, 't2');
|
||||
diag ("---");
|
||||
diag ($output);
|
||||
diag ("---");
|
||||
|
||||
# Cleanup.
|
||||
unlink 'import.txt';
|
||||
|
|
|
@ -46,7 +46,8 @@ my $output = qx{../task rc:seq.rc info 1};
|
|||
like ($output, qr/Status\s+Completed/, 'sequence do 1');
|
||||
$output = qx{../task rc:seq.rc info 2};
|
||||
like ($output, qr/Status\s+Completed/, 'sequence do 2');
|
||||
qx{../task rc:seq.rc undo 1,2};
|
||||
qx{echo 'y'|../task rc:seq.rc undo};
|
||||
qx{echo 'y'|../task rc:seq.rc undo};
|
||||
$output = qx{../task rc:seq.rc info 1};
|
||||
like ($output, qr/Status\s+Pending/, 'sequence undo 1');
|
||||
$output = qx{../task rc:seq.rc info 2};
|
||||
|
@ -58,11 +59,12 @@ $output = qx{../task rc:seq.rc info 1};
|
|||
like ($output, qr/Status\s+Deleted/, 'sequence delete 1');
|
||||
$output = qx{../task rc:seq.rc info 2};
|
||||
like ($output, qr/Status\s+Deleted/, 'sequence delete 2');
|
||||
qx{../task rc:seq.rc undelete 1,2};
|
||||
qx{echo 'y'|../task rc:seq.rc undo};
|
||||
qx{echo 'y'|../task rc:seq.rc undo};
|
||||
$output = qx{../task rc:seq.rc info 1};
|
||||
like ($output, qr/Status\s+Pending/, 'sequence undelete 1');
|
||||
like ($output, qr/Status\s+Pending/, 'sequence undo 1');
|
||||
$output = qx{../task rc:seq.rc info 2};
|
||||
like ($output, qr/Status\s+Pending/, 'sequence undelete 2');
|
||||
like ($output, qr/Status\s+Pending/, 'sequence undo 2');
|
||||
|
||||
# Test sequences in start/stop
|
||||
qx{../task rc:seq.rc start 1,2};
|
||||
|
|
|
@ -51,7 +51,7 @@ $output = qx{../task rc:shadow.rc delete 1};
|
|||
like ($output, qr/\[Shadow file '\.\/shadow\.txt' updated\]/, 'shadow file updated on delete');
|
||||
|
||||
$output = qx{../task rc:shadow.rc list};
|
||||
like ($output, qr/\[Shadow file '\.\/shadow\.txt' updated\]/, 'shadow file updated on list');
|
||||
unlike ($output, qr/\[Shadow file '\.\/shadow\.txt' updated\]/, 'shadow file not updated on list');
|
||||
|
||||
# Inspect the shadow file.
|
||||
my $file = slurp ('./shadow.txt');
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 17;
|
||||
use Test::More tests => 15;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'undo.rc')
|
||||
|
@ -48,17 +48,13 @@ $output = qx{../task rc:undo.rc do 1; ../task rc:undo.rc info 1};
|
|||
ok (-r 'completed.data', 'completed.data created');
|
||||
like ($output, qr/Status\s+Completed\n/, 'Completed');
|
||||
|
||||
$output = qx{../task rc:undo.rc undo 1; ../task rc:undo.rc info 1};
|
||||
$output = qx{echo 'y'|../task rc:undo.rc undo; ../task rc:undo.rc info 1};
|
||||
ok (-r 'completed.data', 'completed.data created');
|
||||
like ($output, qr/Status\s+Pending\n/, 'Pending');
|
||||
|
||||
$output = qx{../task rc:undo.rc do 1; ../task rc:undo.rc list};
|
||||
like ($output, qr/No matches/, 'No matches');
|
||||
|
||||
$output = qx{../task rc:undo.rc undo 1; ../task rc:undo.rc info 1};
|
||||
like ($output, qr/Task 1 not found/, 'Task 1 not found');
|
||||
like ($output, qr/Task 1 not found/, 'No matches');
|
||||
|
||||
# Cleanup.
|
||||
ok (-r 'pending.data', 'Need to remove pending.data');
|
||||
unlink 'pending.data';
|
||||
|
|
|
@ -83,15 +83,15 @@ int main (int argc, char** argv)
|
|||
Task rightAgain (right);
|
||||
|
||||
std::string output = taskDifferences (left, right);
|
||||
t.ok (taskDiff (left, right), "Detected changes");
|
||||
t.ok (output.find ("zero was changed from '0' to '00'.") != std::string::npos, "Detected change zero:0 -> zero:00");
|
||||
t.ok (output.find ("one was deleted.") != std::string::npos, "Detected deletion one:1 ->");
|
||||
t.ok (output.find ("two") == std::string::npos, "Detected no change two:2 -> two:2");
|
||||
t.ok (output.find ("three was set to '3'.") != std::string::npos, "Detected addition -> three:3");
|
||||
t.ok (taskDiff (left, right), "Detected changes");
|
||||
t.ok (output.find ("zero was changed from '0' to '00'") != std::string::npos, "Detected change zero:0 -> zero:00");
|
||||
t.ok (output.find ("one was deleted") != std::string::npos, "Detected deletion one:1 ->");
|
||||
t.ok (output.find ("two") == std::string::npos, "Detected no change two:2 -> two:2");
|
||||
t.ok (output.find ("three was set to '3'") != std::string::npos, "Detected addition -> three:3");
|
||||
|
||||
t.notok (taskDiff (right, rightAgain), "No changes detected");
|
||||
t.notok (taskDiff (right, rightAgain), "No changes detected");
|
||||
output = taskDifferences (right, rightAgain);
|
||||
t.ok (output.find ("No changes were made.") != std::string::npos, "No changes detected");
|
||||
t.ok (output.find ("No changes were made") != std::string::npos, "No changes detected");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue