- Import was not properly handling tags as a JSON array.  It assumed it
  was a string.
- Modified roundtrip.t tests so they work.
This commit is contained in:
Paul Beckingham 2011-08-28 17:21:49 -04:00
parent 6ab7cec36c
commit de5bee4353
2 changed files with 42 additions and 24 deletions

View file

@ -123,6 +123,20 @@ int CmdImport::execute (std::string& output)
task.set (i->first, d.toEpochString ()); task.set (i->first, d.toEpochString ());
} }
// Tags are an array of JSON strings.
else if (i->first == "tags")
{
json::array* tags = (json::array*)i->second;
json_array_iter t;
for (t = tags->_data.begin ();
t != tags->_data.end ();
++t)
{
json::string* tag = (json::string*)*t;
task.addTag (tag->_data);
}
}
// Other types are simply added. // Other types are simply added.
else else
task.set (i->first, unquoteText (i->second->dump ())); task.set (i->first, unquoteText (i->second->dump ()));
@ -158,6 +172,21 @@ int CmdImport::execute (std::string& output)
task.setAnnotations (annos); task.setAnnotations (annos);
} }
// TODO Implement
else if (i->first == "parent")
{
}
// TODO Implement
else if (i->first == "mask")
{
}
// TODO Implement
else if (i->first == "imask")
{
}
else else
throw std::string ("Unrecognized attribute '") + i->first + "'"; throw std::string ("Unrecognized attribute '") + i->first + "'";
} }

View file

@ -28,12 +28,13 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 10; use Test::More tests => 4;
# Create the rc file. # Create the rc file.
if (open my $fh, '>', 'roundtrip.rc') if (open my $fh, '>', 'roundtrip.rc')
{ {
print $fh "data.location=.\n", print $fh "data.location=.\n",
"verbose=off\n",
"confirmation=no\n", "confirmation=no\n",
"defaultwidth=100\n"; "defaultwidth=100\n";
close $fh; close $fh;
@ -45,12 +46,12 @@ qx{../src/task rc:roundtrip.rc add priority:H project:A one};
qx{../src/task rc:roundtrip.rc add +tag1 +tag2 two}; qx{../src/task rc:roundtrip.rc add +tag1 +tag2 two};
# trip 1. # trip 1.
qx{../src/task rc:roundtrip.rc export.yaml > ./roundtrip.txt}; qx{../src/task rc:roundtrip.rc export > ./roundtrip.txt};
unlink 'pending.data', 'completed.data', 'undo.data'; unlink 'pending.data', 'completed.data', 'undo.data';
qx{../src/task rc:roundtrip.rc import ./roundtrip.txt}; qx{../src/task rc:roundtrip.rc rc.debug:1 import ./roundtrip.txt};
# trip 2. # trip 2.
qx{../src/task rc:roundtrip.rc export.yaml > ./roundtrip.txt}; qx{../src/task rc:roundtrip.rc export > ./roundtrip.txt};
unlink 'pending.data', 'completed.data', 'undo.data'; unlink 'pending.data', 'completed.data', 'undo.data';
qx{../src/task rc:roundtrip.rc import ./roundtrip.txt}; qx{../src/task rc:roundtrip.rc import ./roundtrip.txt};
@ -65,26 +66,14 @@ like ($output, qr/1.+A.+H.+\d+\/\d+\/\d+.+(?:-|\d+).+one/, '2 round trips
like ($output, qr/2.+\d+\/\d+\/\d+.+(?:-|\d+).+tag1\stag2\stwo/, '2 round trips task 2 identical'); like ($output, qr/2.+\d+\/\d+\/\d+.+(?:-|\d+).+tag1\stag2\stwo/, '2 round trips task 2 identical');
# Cleanup. # Cleanup.
unlink 'roundtrip.txt'; unlink qw(roundtrip.txt pending.data completed.data undo.data backlog.data synch.key roundtrip.rc);
ok (!-r 'roundtrip.txt', 'Removed roundtrip.txt'); ok (! -r 'roundtrip.txt' &&
! -r 'pending.data' &&
unlink 'pending.data'; ! -r 'completed.data' &&
ok (!-r 'pending.data', 'Removed pending.data'); ! -r 'undo.data' &&
! -r 'backlog.data' &&
unlink 'completed.data'; ! -r 'synch_key.data' &&
ok (!-r 'completed.data', 'Removed completed.data'); ! -r 'roundtrip.rc', 'Cleanup');
unlink 'undo.data';
ok (!-r 'undo.data', 'Removed undo.data');
unlink 'backlog.data';
ok (!-r 'backlog.data', 'Removed backlog.data');
unlink 'synch.key';
ok (!-r 'synch.key', 'Removed synch.key');
unlink 'roundtrip.rc';
ok (!-r 'roundtrip.rc', 'Removed roundtrip.rc');
exit 0; exit 0;