From 4537d5048e744b202d67eed536f9e006b5ebdcac Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 20 Mar 2009 18:12:11 -0400 Subject: [PATCH] Unit Tests - confirmation - Implemented unit tests to very that "confirmation=yes" works. - Implemented unit tests to very that \n causes a re-prompt. - Updated docs with regard to this fix, thanks to Bruce Dillahunty. --- AUTHORS | 1 + ChangeLog | 2 + html/task.html | 2 + src/tests/confirmation.t | 109 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100755 src/tests/confirmation.t diff --git a/AUTHORS b/AUTHORS index 24ed74b2f..da34c53d2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -26,4 +26,5 @@ With thanks to: Russell Friesenhahn Paolo Marsi Eric Farris + Bruce Dillahunty diff --git a/ChangeLog b/ChangeLog index a9a613e64..4f7968d21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ + Added support for the "weekdays" recurrence, which means a task can recur five times a week, and not on weekends (thanks to Chris Pride). + UTF8 text is now supported in task project names, tags and descriptions. + + Fixed bug that caused the y/n confirmation on task deletion to ignore the + Enter key and fail to re-prompt (thanks to Bruce Dillahunty). ------ old releases ------------------------------ diff --git a/html/task.html b/html/task.html index 5e994f555..96d4f9b72 100644 --- a/html/task.html +++ b/html/task.html @@ -103,6 +103,8 @@
  • Added support for the "weekdays" recurrence, which means a task can recur five times a week, and not on weekends (thanks to Chris Pride).
  • UTF8 text is now supported in task project names, tags and descriptions. +
  • Fixed bug that caused the y/n confirmation on task deletion to ignore the + Enter key and fail to re-prompt (thanks to Bruce Dillahunty).

    diff --git a/src/tests/confirmation.t b/src/tests/confirmation.t new file mode 100755 index 000000000..99bc8e378 --- /dev/null +++ b/src/tests/confirmation.t @@ -0,0 +1,109 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 26; + +# Create the rc file. +if (open my $fh, '>', 'confirm.rc') +{ + print $fh "data.location=.\n", + "confirmation=yes\n"; + close $fh; + ok (-r 'confirm.rc', 'Created confirm.rc'); +} + +# Create the response file. +if (open my $fh, '>', 'response.txt') +{ + print $fh "\n\nn\n"; + close $fh; + ok (-r 'response.txt', 'Created response.txt'); +} + +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'); +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'); +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'); +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'); +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'); +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'); +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/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/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/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/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'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'response.txt'; +ok (!-r 'response.txt', 'Removed response.txt'); + +unlink 'confirm.rc'; +ok (!-r 'confirm.rc', 'Removed confirm.rc'); + +exit 0; +