From 92ba36bdec79d14c2e64fc9f5aa1c91273fe27ac Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 16 Feb 2009 23:12:04 -0500 Subject: [PATCH] Unit Tests - add, delete, info, /// - Began set of high-level integration tests, in Perl. --- src/Config.cpp | 2 -- src/tests/add.t | 72 +++++++++++++++++++++++++++++++++++++++++++++++ src/tests/basic.t | 57 +++++++++++++++++++++++++++++++++++++ src/tests/in | 15 ---------- 4 files changed, 129 insertions(+), 17 deletions(-) create mode 100755 src/tests/add.t create mode 100755 src/tests/basic.t delete mode 100755 src/tests/in diff --git a/src/Config.cpp b/src/Config.cpp index 3f46613a0..fee5cf39a 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -39,8 +39,6 @@ Config::Config () { // These are default (but overridable) reports. - (*this)["report.large.columns"] = "id,uuid,project,priority,entry,start,due,age,active,tags,description"; - (*this)["report.large.sort"] = "due+,priority-,project+"; (*this)["report.long.columns"] = "id,project,priority,entry,start,due,age,tags,description"; (*this)["report.long.sort"] = "due+,priority-,project+"; (*this)["report.list.columns"] = "id,project,priority,due,active,age,description"; diff --git a/src/tests/add.t b/src/tests/add.t new file mode 100755 index 000000000..26a82f0ee --- /dev/null +++ b/src/tests/add.t @@ -0,0 +1,72 @@ +#! /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 => 14; + +# Create the rc file. +if (open my $fh, '>', 'add.rc') +{ + print $fh "data.location=.\n"; + close $fh; + ok (-r 'add.rc', 'Created add.rc'); +} + +# Test the add command. +my $output = qx{../task rc:add.rc add This is a test; ../task rc:add.rc info 1}; +like ($output, qr/ID\s+1\n/, 'add ID'); +like ($output, qr/Description\s+This is a test\n/, 'add ID'); +like ($output, qr/Status\s+Pending\n/, 'add Pending'); +like ($output, qr/UUID\s+[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\n/, 'add UUID'); + +# Test the /// modifier. +$output = qx{../task rc:add.rc 1 /test/TEST/; ../task rc:add.rc 1 "/is //"; ../task rc:add.rc info 1}; +like ($output, qr/ID\s+1\n/, 'add ID'); +like ($output, qr/Status\s+Pending\n/, 'add Pending'); +like ($output, qr/Description\s+This a TEST\n/, 'add ID'); + +# Test delete. +$output = qx{../task rc:add.rc delete 1; ../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. +$output = qx{../task rc:add.rc undelete 1; ../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 'pendind.data', 'Removed pending.data'); + +unlink 'add.rc'; +ok (!-r 'add.rc', 'Removed add.rc'); + +exit 0; + diff --git a/src/tests/basic.t b/src/tests/basic.t new file mode 100755 index 000000000..e369b773d --- /dev/null +++ b/src/tests/basic.t @@ -0,0 +1,57 @@ +#! /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 => 7; + +# Create the rc file. +if (open my $fh, '>', 'basic.rc') +{ + print $fh "data.location=.\n"; + close $fh; + ok (-r 'basic.rc', 'Created basic.rc'); +} + +# Test the usage command. +my $output = qx{../task rc:basic.rc}; +like ($output, qr/Usage: task/, 'usage'); +like ($output, qr/http:\/\/www\.beckingham\.net\/task\.html/, 'usage - url'); + +# Test the version command. +$output = qx{../task rc:basic.rc version}; +like ($output, qr/task \d+\.\d+\.\d+/, 'version - task version number'); +like ($output, qr/ABSOLUTELY NO WARRANTY/, 'version - warranty'); +like ($output, qr/http:\/\/www\.beckingham\.net\/task\.html/, 'version - url'); + +# Cleanup. +unlink 'basic.rc'; +ok (!-r 'basic.rc', 'Removed basic.rc'); + +exit 0; + diff --git a/src/tests/in b/src/tests/in deleted file mode 100755 index 761c1f877..000000000 --- a/src/tests/in +++ /dev/null @@ -1,15 +0,0 @@ -./task add monday due:monday -./task add tuesday due:tuesday -./task add wednesday due:wednesday -./task add thursday due:thursday -./task add friday due:friday -./task add saturday due:saturday -./task add sunday due:sunday -./task add yesterday due:yesterday -./task add today due:today -./task add tomorrow due:tomorrow -./task add eow due:eow -./task add eom due:eom -./task add eoy due:eoy -./task add 21st due:21st -