Annotation of todotxt/Text-Todo/t/list.t, Revision 1.2
1.1 andrew 1: #===============================================================================
2: #
3: # FILE: list.t
4: #
5: # DESCRIPTION: Test list commands
6: #
7: #
8: # AUTHOR: Andrew Fresh (AAF), andrew@cpan.org
9: # COMPANY: Red River Communications
10: # CREATED: 01/07/10 19:11
1.2 ! andrew 11: # REVISION: $RedRiver: list.t,v 1.1 2010/01/08 04:38:44 andrew Exp $
1.1 andrew 12: #===============================================================================
13:
14: use strict;
15: use warnings;
16:
1.2 ! andrew 17: use Test::More; #tests => 2;
! 18:
! 19: use File::Temp qw/ tempdir /;
! 20: use Data::Dumper;
1.1 andrew 21:
22: my $class = 'Text::Todo';
23:
24: BEGIN: { use_ok( $class, "use $class" ) }
25:
26: diag("Testing entry $class $Text::Todo::VERSION");
27:
1.2 ! andrew 28: my $orig = new_ok( $class, ['t/todo.list.txt'] );
! 29: my @orig_list;
! 30: ok( @orig_list = $orig->list, 'get orig list' );
! 31:
! 32: is( $orig->file('todo_file'), 't/todo.list.txt', 'orig todo_file matches' );
! 33: is( $orig->file('done_file'), 't/done.list.txt', 'orig done_file matches' );
! 34: is( $orig->file('report_file'),
! 35: 't/report.list.txt', 'orig report_file matches' );
! 36:
! 37: my $todo_dir = tempdir( 'todo-XXXXXXXXX', CLEANUP => 1, TMPDIR => 1 );
! 38: my $copy = new_ok($class);
! 39:
! 40: foreach my $e (@orig_list) {
! 41: ok( $copy->add($e), 'add entry from orginal list' );
! 42: }
! 43: ok( $copy->save( $todo_dir . '/todo.txt' ), 'save the copy' );
! 44:
! 45: is( $copy->file('todo_file'),
! 46: $todo_dir . '/todo.txt',
! 47: 'copy todo_file matches'
! 48: );
! 49: is( $copy->file('done_file'),
! 50: $todo_dir . '/done.txt',
! 51: 'copy done_file matches'
! 52: );
! 53: is( $copy->file('report_file'),
! 54: $todo_dir . '/report.txt',
! 55: 'copy report_file matches'
! 56: );
! 57: my @copy_list;
! 58: ok( @copy_list = $copy->list, 'get copy list' );
1.1 andrew 59:
1.2 ! andrew 60: for my $id ( 0 .. $#orig_list ) {
! 61: is( $copy_list[$id]->text, $orig_list[$id]->text, "Entry $id matches" );
! 62: }
! 63:
! 64: $orig = undef;
! 65:
! 66: my @pri_list;
! 67: ok( @pri_list = $copy->listpri, 'load priority item' );
! 68: is( scalar @pri_list, 1, 'only 1 item in the priority list' );
! 69: is( $pri_list[0]->text, '(A) entry 1 @one +uno', 'priority item is correct' );
! 70:
! 71: my $entry_to_move = $copy_list[-1];
! 72: ok( $copy->move( $entry_to_move, 1 ), 'move entry to position 1' );
! 73: ok( @copy_list = $copy->list, 'update our list' );
! 74: is( $copy_list[1]->text, $entry_to_move->text,
! 75: 'entry is in the new position' );
! 76:
! 77: $entry_to_move = $copy_list[3];
! 78: ok( $copy->move( 3, 1 ), 'move entry 3 to position 1' );
! 79: ok( @copy_list = $copy->list, 'update our list' );
! 80: is( $copy_list[1]->text, $entry_to_move->text,
! 81: 'entry is in the new position' );
! 82:
! 83: my @projects;
! 84: ok( @projects = $copy->listproj, 'listproj for current list' );
! 85: is_deeply(
! 86: \@projects,
! 87: [ 'delete', 'dos', 'uno' ],
! 88: 'got the projects we expected'
1.1 andrew 89: );
90:
1.2 ! andrew 91: for my $id ( 0 .. $#copy_list ) {
! 92: my $e = $copy_list[$id];
! 93: if ( $e->in_project('delete') ) {
! 94: ok( $copy->del($e), "deleting entry $id" );
! 95: isnt( $copy->list->[$id]->text, $e->text, 'Entry seems to be gone' );
! 96: }
! 97: }
! 98:
! 99: @projects;
! 100: ok( @projects = $copy->listproj, 'listproj for current list' );
! 101: is_deeply( \@projects, [ 'dos', 'uno' ], 'got the projects we expected' );
! 102:
! 103: TODO: {
! 104: local $TODO = 'No tests for archive and it isn\'t even written yet';
! 105: ok( $copy->archive );
! 106: }
! 107:
! 108: TODO: {
! 109: local $TODO = 'No tests for addto and it isn\'t even written yet';
! 110: ok( $copy->addto );
! 111: }
! 112:
! 113: TODO: {
! 114: local $TODO = 'No tests for listfile and it isn\'t even written yet';
! 115: ok( $copy->listfile );
! 116: }
! 117:
! 118: done_testing();
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>