File Import

- Implemented all remaining import functionality.
This commit is contained in:
Paul Beckingham 2009-03-29 17:42:11 -04:00
parent 5f4563af2f
commit 25425614b1
6 changed files with 354 additions and 22 deletions

70
src/tests/import.csv.t Executable file
View file

@ -0,0 +1,70 @@
#! /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 => 8;
# Create the rc file.
if (open my $fh, '>', 'import.rc')
{
print $fh "data.location=.\n";
close $fh;
ok (-r 'import.rc', 'Created import.rc');
}
# Create import file.
if (open my $fh, '>', 'import.txt')
{
print $fh "'id','priority','description'\n",
"1,H,'this is a test'\n",
"2,,'another task'\n",
"\n";
close $fh;
ok (-r 'import.txt', 'Created sample import data');
}
my $output = qx{../task rc:import.rc import import.txt};
is ($output, "Imported 2 tasks successfully, with 0 errors.\n", 'no errors');
$output = qx{../task rc:import.rc list};
like ($output, qr/1.+H.+this is a test/, 't1');
like ($output, qr/2.+another task/, 't2');
# Cleanup.
unlink 'import.txt';
ok (!-r 'import.txt', 'Removed import.txt');
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data');
unlink 'import.rc';
ok (!-r 'import.rc', 'Removed import.rc');
exit 0;