From df652d2ec7129b8a57dcfb68488550e2a529184c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 21 May 2011 10:35:46 -0400 Subject: [PATCH] Unit Tests - Added unit tests to verify that appending or prepending nothing generates an error. --- test/append.t | 8 ++++++-- test/prepend.t | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/append.t b/test/append.t index 46b8b3e89..a63b22719 100755 --- a/test/append.t +++ b/test/append.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 7; # Create the rc file. if (open my $fh, '>', 'append.rc') @@ -38,12 +38,16 @@ if (open my $fh, '>', 'append.rc') ok (-r 'append.rc', 'Created append.rc'); } -# Add a task, then append more decsription. +# Add a task, then append more description. qx{../src/task rc:append.rc add foo}; qx{../src/task rc:append.rc 1 append bar}; my $output = qx{../src/task rc:append.rc info 1}; like ($output, qr/Description\s+foo\sbar\n/, 'append worked'); +# Should cause an error when nothing is appended. +$output = qx{../src/task rc:append.rc append 1}; +unlike ($output, qr/Appended 0 tasks/, 'blank append failed'); + # Cleanup. unlink 'pending.data'; ok (!-r 'pending.data', 'Removed pending.data'); diff --git a/test/prepend.t b/test/prepend.t index 2f1906435..c2f71fe65 100755 --- a/test/prepend.t +++ b/test/prepend.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 7; # Create the rc file. if (open my $fh, '>', 'prepend.rc') @@ -44,6 +44,10 @@ qx{../src/task rc:prepend.rc 1 prepend foo}; my $output = qx{../src/task rc:prepend.rc info 1}; like ($output, qr/Description\s+foo\sbar\n/, 'prepend worked'); +# Should cause an error when nothing is appended. +$output = qx{../src/task rc:prepend.rc prepend 1}; +unlike ($output, qr/Prepended 0 tasks/, 'blank prepend failed'); + # Cleanup. unlink 'pending.data'; ok (!-r 'pending.data', 'Removed pending.data');