- Implemented export.yaml, import (yaml). - Updated man page. - 'export' is now an alias to 'export.yaml'. - Added missing 'tags' attribute as an internal Att. - Improved recognition of YAML. - Added unit tests for export.yaml, import (yaml). - Added missing unlink from dependencies.t
This commit is contained in:
@@ -41,7 +41,7 @@ if (open my $fh, '>', 'export.rc')
|
||||
# Add two tasks, export, examine result.
|
||||
qx{../task rc:export.rc add priority:H project:A one};
|
||||
qx{../task rc:export.rc add +tag1 +tag2 two};
|
||||
qx{../task rc:export.rc export > ./export.txt};
|
||||
qx{../task rc:export.rc export.csv > ./export.txt};
|
||||
|
||||
my @lines;
|
||||
if (open my $fh, '<', './export.txt')
|
||||
84
src/tests/export.yaml.t
Executable file
84
src/tests/export.yaml.t
Executable file
@@ -0,0 +1,84 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, 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 => 21;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'export.rc')
|
||||
{
|
||||
print $fh "data.location=.\n";
|
||||
close $fh;
|
||||
ok (-r 'export.rc', 'Created export.rc');
|
||||
}
|
||||
|
||||
# Add two tasks, export, examine result.
|
||||
qx{../task rc:export.rc add priority:H project:A one};
|
||||
qx{../task rc:export.rc add +tag1 +tag2 two};
|
||||
qx{../task rc:export.rc export.yaml | tail +2 > ./export.txt};
|
||||
|
||||
my @lines;
|
||||
if (open my $fh, '<', './export.txt')
|
||||
{
|
||||
@lines = <$fh>;
|
||||
close $fh;
|
||||
}
|
||||
|
||||
like ($lines[0], qr/^%YAML 1.1$/, 'export.yaml line 0');
|
||||
like ($lines[1], qr/^---$/, 'export.yaml line 1');
|
||||
like ($lines[2], qr/^ task:$/, 'export.yaml line 2');
|
||||
like ($lines[3], qr/^ description: one$/, 'export.yaml line 3');
|
||||
like ($lines[4], qr/^ entry: \d+$/, 'export.yaml line 4');
|
||||
like ($lines[5], qr/^ priority: H$/, 'export.yaml line 5');
|
||||
like ($lines[6], qr/^ project: A$/, 'export.yaml line 6');
|
||||
like ($lines[7], qr/^ status: pending$/, 'export.yaml line 7');
|
||||
like ($lines[8], qr/^ uuid: .+$/, 'export.yaml line 8');
|
||||
like ($lines[9], qr/^ task:$/, 'export.yaml line 9');
|
||||
like ($lines[10], qr/^ description: two$/, 'export.yaml line 10');
|
||||
like ($lines[11], qr/^ entry: \d+$/, 'export.yaml line 11');
|
||||
like ($lines[12], qr/^ status: pending$/, 'export.yaml line 12');
|
||||
like ($lines[13], qr/^ tags: tag1,tag2$/, 'export.yaml line 13');
|
||||
like ($lines[14], qr/^ uuid: .+$/, 'export.yaml line 14');
|
||||
like ($lines[15], qr/^\.\.\.$/, 'export.yaml line 15');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'export.txt';
|
||||
ok (!-r 'export.txt', 'Removed export.txt');
|
||||
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'export.rc';
|
||||
ok (!-r 'export.rc', 'Removed export.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
96
src/tests/import.yaml.t
Executable file
96
src/tests/import.yaml.t
Executable file
@@ -0,0 +1,96 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, 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 => 11;
|
||||
|
||||
# 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 <<EOF;
|
||||
%YAML 1.1
|
||||
---
|
||||
task:
|
||||
uuid: 00000000-0000-0000-0000-000000000000
|
||||
description: zero
|
||||
project: A
|
||||
status: pending
|
||||
task:
|
||||
uuid: 11111111-1111-1111-1111-111111111111
|
||||
description: one
|
||||
project: B
|
||||
status: pending
|
||||
task:
|
||||
uuid: 22222222-2222-2222-2222-222222222222
|
||||
description: two
|
||||
status: completed
|
||||
end: 1234567890
|
||||
...
|
||||
EOF
|
||||
|
||||
close $fh;
|
||||
ok (-r 'import.txt', 'Created sample import data');
|
||||
}
|
||||
|
||||
my $output = qx{../task rc:import.rc import import.txt};
|
||||
like ($output, qr/Imported 3 tasks successfully./, 'no errors');
|
||||
|
||||
$output = qx{../task rc:import.rc list};
|
||||
like ($output, qr/1.+A.+zero/, 't1');
|
||||
like ($output, qr/2.+B.+one/, 't2');
|
||||
|
||||
$output = qx{../task rc:import.rc completed};
|
||||
like ($output, qr/2\/13\/2009.+two/, 't3');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'import.txt';
|
||||
ok (!-r 'import.txt', 'Removed import.txt');
|
||||
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'completed.data';
|
||||
ok (!-r 'completed.data', 'Removed completed.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'import.rc';
|
||||
ok (!-r 'import.rc', 'Removed import.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
Reference in New Issue
Block a user