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

File: [local] / todotxt / Text-Todo / t / read_todo.t (download)

Revision 1.2, Mon Jul 13 17:50:37 2009 UTC (14 years, 11 months ago) by andrew
Branch: MAIN
Changes since 1.1: +7 -2 lines

email addresses are not contexts.  As a bigger thing, only match tags that are tags

#
#===============================================================================
#
#         FILE:  50.read_todo.t
#
#  DESCRIPTION:  Reads in a sample todo.txt and makes sure it got it correctly
#
#       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org
#      COMPANY:  Red River Communications
#      CREATED:  07/09/09 11:45:52
#     REVISION:  $RedRiver: 50.read_todo.t,v 1.1 2009/07/10 22:26:14 andrew Exp $
#===============================================================================

use strict;
use warnings;
use File::Spec;
use Test::More tests => 28;

my $todo_file = File::Spec->catfile( 't', 'todo1.txt' );
my @todos = (
    {   text     => '(B) +GarageSale @phone schedule Goodwill pickup',
        priority => 'B',
        contexts => ['phone'],
        projects => ['GarageSale'],
    },
    {   text =>
            '+GarageSale @home post signs around the neighborhood DUE:2006-08-01',
        priority => undef,
        contexts => ['home'],
        projects => ['GarageSale'],
    },
    {   text     => 'eat meatballs @home',
        priority => undef,
        contexts => ['home'],
        projects => [],
    },
    {   text     => '(A) @phone thank Mom for the meatballs WAIT',
        priority => 'A',
        contexts => ['phone'],
        projects => [],
    },
    {   text     => '@shopping Eskimo pies',
        priority => undef,
        contexts => ['shopping'],
        projects => [],
    },
    {   text     => 'email andrew@cpan.org for help +report_bug @wherever',
        priority => undef,
        contexts => ['wherever'],
        projects => ['report_bug'],
    },
);

BEGIN: { use_ok( 'Text::Todo', 'use Text::Todo' ) }

diag("Testing 50 read Text::Todo $Text::Todo::VERSION");

my $todo = new_ok('Text::Todo');

#ok( $todo->load(), 'Load no file');

ok( $todo->load($todo_file), "Load file [$todo_file]" );

my $list;
ok( $list = $todo->list, 'Get list' );

for my $id ( 0 .. $#todos ) {
    my $sample = $todos[$id];
    my $read   = $list->[$id];

    is( $read->text,     $sample->{text},     "check text [$id]" );
    is( $read->priority, $sample->{priority}, "check priority [$id]" );
    is_deeply(
        [ $read->contexts ],
        $sample->{contexts},
        "check contexts [$id]"
    );
    is_deeply(
        [ $read->projects ],
        $sample->{projects},
        "check projects [$id]"
    );
}