mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit Tests - confirmation, delete, subst, undo
- Modified unit tests to accommodate changes in the verbose output of task. - Added tests to verify /delete-me// substitutions. - Fixed typos in test descriptions.
This commit is contained in:
parent
98391a0c24
commit
fea19e036a
4 changed files with 25 additions and 15 deletions
|
@ -51,49 +51,49 @@ qx{../task rc:confirm.rc add foo} for 1 .. 10;
|
|||
|
||||
# Test the various forms of "yes".
|
||||
my $output = qx{echo "yes" | ../task rc:confirm.rc del 1};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - yes works');
|
||||
like ($output, qr/Permanently delete task 1 'foo'\? \(y\/n\)/, 'confirmation - yes works');
|
||||
unlike ($output, qr/Task not deleted\./, 'confirmation - yes works');
|
||||
|
||||
$output = qx{echo "ye" | ../task rc:confirm.rc del 2};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - ye works');
|
||||
like ($output, qr/Permanently delete task 2 'foo'\? \(y\/n\)/, 'confirmation - ye works');
|
||||
unlike ($output, qr/Task not deleted\./, 'confirmation - ye works');
|
||||
|
||||
$output = qx{echo "y" | ../task rc:confirm.rc del 3};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - y works');
|
||||
like ($output, qr/Permanently delete task 3 'foo'\? \(y\/n\)/, 'confirmation - y works');
|
||||
unlike ($output, qr/Task not deleted\./, 'confirmation - y works');
|
||||
|
||||
$output = qx{echo "YES" | ../task rc:confirm.rc del 4};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - YES works');
|
||||
like ($output, qr/Permanently delete task 4 'foo'\? \(y\/n\)/, 'confirmation - YES works');
|
||||
unlike ($output, qr/Task not deleted\./, 'confirmation - YES works');
|
||||
|
||||
$output = qx{echo "YE" | ../task rc:confirm.rc del 5};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - YE works');
|
||||
like ($output, qr/Permanently delete task 5 'foo'\? \(y\/n\)/, 'confirmation - YE works');
|
||||
unlike ($output, qr/Task not deleted\./, 'confirmation - YE works');
|
||||
|
||||
$output = qx{echo "Y" | ../task rc:confirm.rc del 6};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - Y works');
|
||||
like ($output, qr/Permanently delete task 6 'foo'\? \(y\/n\)/, 'confirmation - Y works');
|
||||
unlike ($output, qr/Task not deleted\./, 'confirmation - Y works');
|
||||
|
||||
# Test the various forms of "no".
|
||||
$output = qx{echo "no" | ../task rc:confirm.rc del 7};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - no works');
|
||||
like ($output, qr/Permanently delete task 7 'foo'\? \(y\/n\)/, 'confirmation - no works');
|
||||
like ($output, qr/Task not deleted\./, 'confirmation - no works');
|
||||
|
||||
$output = qx{echo "n" | ../task rc:confirm.rc del 7};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - n works');
|
||||
like ($output, qr/Permanently delete task 7 'foo'\? \(y\/n\)/, 'confirmation - n works');
|
||||
like ($output, qr/Task not deleted\./, 'confirmation - n works');
|
||||
|
||||
$output = qx{echo "NO" | ../task rc:confirm.rc del 7};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - NO works');
|
||||
like ($output, qr/Permanently delete task 7 'foo'\? \(y\/n\)/, 'confirmation - NO works');
|
||||
like ($output, qr/Task not deleted\./, 'confirmation - NO works');
|
||||
|
||||
$output = qx{echo "N" | ../task rc:confirm.rc del 7};
|
||||
like ($output, qr/Permanently delete task\? \(y\/n\)/, 'confirmation - N works');
|
||||
like ($output, qr/Permanently delete task 7 'foo'\? \(y\/n\)/, 'confirmation - N works');
|
||||
like ($output, qr/Task not deleted\./, 'confirmation - N works');
|
||||
|
||||
# Test newlines.
|
||||
$output = qx{cat response.txt | ../task rc:confirm.rc del 7};
|
||||
like ($output, qr/(Permanently delete task\? \(y\/n\)) \1 \1/, 'confirmation - \n re-prompt works');
|
||||
like ($output, qr/(Permanently delete task 7 'foo'\? \(y\/n\)) \1 \1/, 'confirmation - \n re-prompt works');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
|
|
|
@ -57,7 +57,7 @@ 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/reliably undeleted/, 'can only be reliable undeleted...');
|
||||
like ($output, qr/Task 1 not found/, 'Task 1 not found');
|
||||
|
||||
$output = qx{../task rc:undelete.rc info 1};
|
||||
like ($output, qr/No matches./, 'no matches');
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
use Test::More tests => 9;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'subst.rc')
|
||||
|
@ -58,6 +58,16 @@ qx{../task rc:subst.rc 1 /bar/BAR/g};
|
|||
$output = qx{../task rc:subst.rc info 1};
|
||||
like ($output, qr/BAR BAR BAR/, 'global substitution in annotation');
|
||||
|
||||
qx{../task rc:subst.rc 1 /FOO/aaa/};
|
||||
qx{../task rc:subst.rc 1 /FOO/bbb/};
|
||||
qx{../task rc:subst.rc 1 /FOO/ccc/};
|
||||
$output = qx{../task rc:subst.rc info 1};
|
||||
like ($output, qr/aaa bbb ccc/, 'individual successive substitution in description');
|
||||
|
||||
qx{../task rc:subst.rc 1 /bbb//};
|
||||
$output = qx{../task rc:subst.rc info 1};
|
||||
like ($output, qr/aaa ccc/, 'word deletion in description');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
|
|
@ -56,8 +56,8 @@ $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 not found');
|
||||
like ($output, qr/reliably undone/, 'can only be reliable undone...');
|
||||
like ($output, qr/Task 1 not found/, 'Task 1 not found');
|
||||
like ($output, qr/No matches/, 'No matches');
|
||||
|
||||
# Cleanup.
|
||||
ok (-r 'pending.data', 'Need to remove pending.data');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue