From bdbe4ba78a6ddfd2eb171aaa882da5493da31153 Mon Sep 17 00:00:00 2001 From: Cory Donnelly Date: Wed, 21 Jul 2010 12:17:49 -0400 Subject: [PATCH] Unit Tests - Added many unit tests to dependencies.t, with many more still to go --- src/tests/dependencies.t | 90 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/src/tests/dependencies.t b/src/tests/dependencies.t index 50a49a5e2..415ef5a26 100755 --- a/src/tests/dependencies.t +++ b/src/tests/dependencies.t @@ -28,20 +28,98 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 19; # Create the rc file. if (open my $fh, '>', 'dep.rc') -{ +{ print $fh "data.location=.\n"; + print $fh "dependency.confirm=yes\n"; + print $fh "report.depreport.columns=id,depends,description\n"; + print $fh "report.depreport.labels=ID,Depends,Description\n"; + print $fh "report.depreport.filter=status:pending"; close $fh; ok (-r 'dep.rc', 'Created dep.rc'); } -# TODO t 1 dep:2; t info 1 => blocked by 2 -# TODO t info 2 => blocking 1 -# TODO t 1 dep:2,3,4; t 1 dep:-2,-4,5; t info 1 => blocked by 3,5 -# TODO t 1 dep:2; t 2 dep:1 => error +qx{../task rc:dep.rc add One}; +qx{../task rc:dep.rc add Two}; + +my $output = qx{../task rc:dep.rc 1 dep:-2}; +like ($output, qr/Modified 0 tasks\./, 'dependencies - remove nonexistent dependency'); + +$output = qx{../task rc:dep.rc 1 dep:99}; +like ($output, qr/Could not create a dependency on task 99 - not found\./, 'dependencies - add dependency for nonexistent task'); + +$output = qx{../task rc:dep.rc 99 dep:1}; +like ($output, qr/Task 99 not found\./, 'dependencies - add dependency to nonexistent task'); + +# t 1 dep:2; t info 1 => blocked by 2 +$output = qx{../task rc:dep.rc 1 dep:2; ../task rc:dep.rc info 1}; +like ($output, qr/This task blocked by\s+2 Two\nThis task is blocking/, 'dependencies - trivial blocked'); + +# t info 2 => blocking 1 +$output = qx{../task rc:dep.rc info 2}; +like ($output, qr/This task is blocking\s+1 One\nUUID/, 'dependencies - trivial blocking'); + +# t 1 dep:2 (again) +$output = qx{../task rc:dep.rc 1 dep:2}; +like ($output, qr/Modified 0 tasks\./, 'dependencies - add already existing dependency'); + +# t 1 dep:2; t 2 dep:1 => error +$output = qx{../task rc:dep.rc 2 dep:1}; +unlike ($output, qr/Modified 1 task\./, 'dependencies - trivial circular'); + +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data for a fresh start'); + +qx{../task rc:dep.rc add One}; +qx{../task rc:dep.rc add Two}; +qx{../task rc:dep.rc add Three}; +qx{../task rc:dep.rc add Four}; +qx{../task rc:dep.rc add Five}; + +qx{../task rc:dep.rc 5 dep:4; ../task rc:dep.rc 4 dep:3; ../task rc:dep.rc 3 dep:2; ../task rc:dep.rc 2 dep:1}; + +# 5 dep 4 dep 3 dep 2 dep 1 dep 5 => error +$output = qx{../task rc:dep.rc 1 dep:5}; +unlike ($output, qr/Modified 1 task\./, 'dependencies - nontrivial circular'); + +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data for a fresh start'); + +qx{../task rc:dep.rc add One}; +qx{../task rc:dep.rc add Two}; +qx{../task rc:dep.rc add Three}; +qx{../task rc:dep.rc add Four}; +qx{../task rc:dep.rc add Five}; +qx{../task rc:dep.rc add Six recurring due:tomorrow recur:daily}; + +$output = qx{../task rc:dep.rc 6 dep:5}; +unlike ($output,qr/Modified \d+ task/, 'dependencies - recurring task depending on another task'); + +$output = qx{../task rc:dep.rc 5 dep:6}; +like ($output,qr/Modified \d+ task/, 'dependencies - task depending on recurring task'); + +# t 1 dep:2,3,4; t 1 dep:-2,-4,5; t info 1 => blocked by 3,5 +$output = qx{../task rc:dep.rc 1 dep:2,3,4; ../task rc:dep.rc 1 dep:-2,-4,5; ../task rc:dep.rc info 1}; +like ($output, qr/This task blocked by\s+3 Three\n\s+5 Five\nThis task is blocking/, 'dependencies - multiple dependencies modified'); + +$output = qx{../task rc:dep.rc do 3,5; ../task rc:dep.rc info 1}; +like ($output, qr/This task blocked by\nThis task is blocking/, 'dependencies - task info reflects completed dependencies'); + +$output = qx{../task rc:dep.rc depreport}; +like ($output, qr/\s1\s+One\s+/, 'dependencies - depends report column reflects completed dependencies'); + +# TODO - test dependency.confirm config variable +# TODO - test dependency chain gap repair on delete +# TODO - test dependency chain gap repair on complete +# TODO - test dependency chain gap repair on dependency removal +# TODO - test for absence of dependency chain gap repair prompt on delete/complete/dependency removal when item is the first or last in the chain +# TODO - test undo on backing out chain gap repair +# TODO - test undo on backing out choice to not perform chain gap repair +# TODO - test blocked task completion nag +# TODO - test depend.any and depend.none report filters # Cleanup. unlink 'pending.data';