[BACK]Return to list.t CVS log [TXT][DIR] Up to [local] / todotxt / Text-Todo / t

Diff for /todotxt/Text-Todo/t/list.t between version 1.1 and 1.15

version 1.1, 2010/01/08 04:38:44 version 1.15, 2010/02/13 23:26:44
Line 8 
Line 8 
 #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org  #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org
 #      COMPANY:  Red River Communications  #      COMPANY:  Red River Communications
 #      CREATED:  01/07/10 19:11  #      CREATED:  01/07/10 19:11
 #     REVISION:  $RedRiver$  #     REVISION:  $AFresh1: list.t,v 1.14 2010/01/20 21:15:15 andrew Exp $
 #===============================================================================  #===============================================================================
   
 use strict;  use strict;
 use warnings;  use warnings;
   
 use Test::More tests => 2;  use Test::More tests => 55;
   
 my $class = 'Text::Todo';  use File::Temp qw/ tempdir /;
   use File::Spec;
   
 BEGIN: { use_ok( $class, "use $class" ) }  my $class;
   
   BEGIN {
       $class = 'Text::Todo';
       use_ok( $class, "use $class" );
   }
   
 diag("Testing entry $class $Text::Todo::VERSION");  diag("Testing entry $class $Text::Todo::VERSION");
   
 my $e = new_ok( $class, [ 't/todo.list.txt' ] );  my $orig = new_ok( $class, ['t/todo.list.txt'] );
   my @orig_list;
   ok( @orig_list = $orig->list, 'get orig list' );
   
 my %commands = (  is( $orig->file('todo_file'),
     add      => {},      File::Spec->catfile( 't', 'todo.list.txt' ),
     archive  => {},      'orig todo_file matches'
     del      => {},  
     list     => {},  
     listall  => {},  
     listcon  => {},  
     listfile => {},  
     listpri  => {},  
     listproj => {},  
     move     => {},  
     replace  => {},  
     report   => {},  
 );  );
   is( $orig->file('done_file'),
       File::Spec->catfile( 't', 'done.list.txt' ),
       'orig done_file matches'
   );
   is( $orig->file('report_file'),
       File::Spec->catfile( 't', 'report.list.txt' ),
       'orig report_file matches'
   );
   
 my %aliases = (  my $todo_dir = tempdir( 'todo-XXXXXXXXX', CLEANUP => 1, TMPDIR => 1 );
     a     => 'add',  my $copy = new_ok($class);
     rm    => 'del',  
     ls    => 'list',  foreach my $e (@orig_list) {
     lsa   => 'listall',      ok( $copy->add($e), 'add entry from orginal list' );
     lsc   => 'listcon',  }
     lf    => 'listfile',  ok( $copy->save( File::Spec->catfile( $todo_dir, 'todo.txt' ) ),
     lspri => 'listpri',      'save the copy' );
     lsprj => 'listproj',  
     mv    => 'move',  is( $copy->file('todo_file'),
       File::Spec->catfile( $todo_dir, 'todo.txt' ),
       'copy todo_file matches'
 );  );
   is( $copy->file('done_file'),
       File::Spec->catfile( $todo_dir, 'done.txt' ),
       'copy done_file matches'
   );
   is( $copy->file('report_file'),
       File::Spec->catfile( $todo_dir, 'report.txt' ),
       'copy report_file matches'
   );
   my @copy_list;
   ok( @copy_list = $copy->list, 'get copy list' );
   
   for my $id ( 0 .. $#orig_list ) {
       is( $copy_list[$id]->text, $orig_list[$id]->text, "Entry $id matches" );
   }
   
   $orig = undef;
   
   my @pri_list;
   ok( @pri_list = $copy->listpri('A'), 'list priority item' );
   is( scalar @pri_list, 1, 'only 1 item in the priority list' );
   is( $pri_list[0]->text, '(A) entry 1 @one +uno', 'priority item is correct' );
   
   my $entry_to_move = $copy_list[-1];
   ok( $copy->move( $entry_to_move, 1 ), 'move entry to position 1' );
   ok( @copy_list = $copy->list, 'update our list' );
   is( $copy_list[1]->text, $entry_to_move->text,
       'entry is in the new position' );
   
   $entry_to_move = $copy_list[3];
   ok( $copy->move( 3, 1 ), 'move entry 3 to position 1' );
   ok( @copy_list = $copy->list, 'update our list' );
   is( $copy_list[1]->text, $entry_to_move->text,
       'entry is in the new position' );
   
   my @tags;
   ok( @tags = $copy->listtags, 'listtagsfor current list' );
   is_deeply(
       \@tags,
       [ 'context', 'project' ],
       'got the projects we expected'
   );
   
   my @projects;
   ok( @projects = $copy->listproj, 'listproj for current list' );
   is_deeply(
       \@projects,
       [ 'delete', 'dos', 'uno' ],
       'got the projects we expected'
   );
   
   for my $id ( 0 .. $#copy_list ) {
       my $e = $copy_list[$id];
       if ( $e->in_project('delete') ) {
           ok( $copy->del($e), "deleting entry $id" );
           isnt( $copy->list->[$id]->text, $e->text, 'Entry seems to be gone' );
       }
   }
   
   ok( @projects = $copy->listproj, 'listproj for current list' );
   is_deeply( \@projects, [ 'dos', 'uno' ], 'got the projects we expected' );
   
   my @contexts;
   ok( @contexts = $copy->listcon, 'listcon for current list' );
   is_deeply( \@contexts, [ 'one', 'two' ], 'got the contexts we expected' );
   
   my $entry_to_archive;
   ok( $entry_to_archive = $copy->list->[3], 'read entry_to_archive' );
   is( $entry_to_archive->text,
       'x completed entry 4',
       'make sure we got the right entry'
   );
   
   ok( $copy->archive, 'archive done items' );
   isnt( $copy->list->[1]->text,
       $entry_to_archive->text, 'make sure it changed' );
   
   ok( $copy->load('done_file'), 'read the done_file' );
   is( $copy->list->[-1]->text,
       $entry_to_archive->text, 'make sure it moved to the archive' );
   
   my $file;
   ok( $file = $copy->file('done_file'), 'get the done_file name' );
   is( $file,
       File::Spec->catfile( $todo_dir, 'done.txt' ),
       'the done_file name what we expected?'
   );
   
   ok( $copy->addto( $file, 'added text' ), 'Add text to file' );
   
   my @done;
   ok( @done = $copy->listfile('done_file'), 'get items in done_file' );
   is( $done[-1]->text, 'added text', 'make sure what we added is there' );
   
   is( $done[-2]->text, $entry_to_archive->text,
       'make sure it moved to the archive' );
   
   #done_testing();

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.15

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>