mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit Tests - export
- Added unit tests to export tasks and compare.
This commit is contained in:
parent
6fade84535
commit
9f278b1ffc
1 changed files with 72 additions and 0 deletions
72
src/tests/export.t
Executable file
72
src/tests/export.t
Executable file
|
@ -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 => 7;
|
||||
|
||||
# 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 ./export.txt};
|
||||
|
||||
my @lines;
|
||||
if (open my $fh, '<', './export.txt')
|
||||
{
|
||||
@lines = <$fh>;
|
||||
close $fh;
|
||||
}
|
||||
|
||||
my $line1 = qr/'id','uuid','status','tags','entry','start','due','end','project','priority','fg','bg','description'\n/;
|
||||
my $line2 = qr/'.{8}-.{4}-.{4}-.{4}-.{12}','pending','',\d+,,,,'A','H',,,'one'\n/;
|
||||
my $line3 = qr/'.{8}-.{4}-.{4}-.{4}-.{12}','pending','tag1 tag2',\d+,,,,,,,,'two'\n/;
|
||||
|
||||
like ($lines[0], $line1, "export line one");
|
||||
like ($lines[1], $line2, "export line two");
|
||||
like ($lines[2], $line3, "export line three");
|
||||
|
||||
# Cleanup.
|
||||
unlink 'export.txt';
|
||||
ok (!-r 'export.txt', 'Removed export.txt');
|
||||
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'export.rc';
|
||||
ok (!-r 'export.rc', 'Removed export.rc');
|
||||
|
||||
exit 0;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue