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

Annotation of todotxt/Text-Todo-REST-API/t/GET/list.t, Revision 1.3

1.1       andrew      1: #===============================================================================
                      2: #
                      3: #         FILE:  GET/list.t
                      4: #
                      5: #  DESCRIPTION:  Test Text::Todo::REST::API
                      6: #
                      7: #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org
                      8: #      COMPANY:  Red River Communications
                      9: #      CREATED:  01/07/10 19:11
1.3     ! andrew     10: #     REVISION:  $AFresh1: list.t,v 1.2 2010/01/18 13:47:53 andrew Exp $
1.1       andrew     11: #===============================================================================
                     12:
                     13: use strict;
                     14: use warnings;
                     15:
1.3     ! andrew     16: use Test::More tests => 17;
1.1       andrew     17:
                     18: my $class;
1.3     ! andrew     19:
1.1       andrew     20: BEGIN {
                     21:     $class = 'Text::Todo::REST::API';
                     22:     use_ok( $class, "use $class" );
                     23: }
                     24:
                     25: diag("Testing GET list $class $Text::Todo::REST::API::VERSION");
                     26:
1.3     ! andrew     27: my $api = new_ok( $class, [ { todo_dir => 't/lists' } ] );
1.1       andrew     28:
                     29: my $list_should_be = [
                     30:     {   'text' => '(A) entry 1 @one +uno',
                     31:         'md5'  => '931e0831c31a70928b29de55778dc294',
                     32:         'line' => 1
                     33:     },
                     34:     {   'text' => 'entry 2 @two +dos',
                     35:         'md5'  => 'b38dde8029c047e81379d9de581a6251',
                     36:         'line' => 2
                     37:     },
                     38:     {   'text' => '',
                     39:         'md5'  => 'd41d8cd98f00b204e9800998ecf8427e',
                     40:         'line' => 3
                     41:     },
                     42:     {   'text' => 'x completed entry 4',
                     43:         'md5'  => '8de0a2b65a50d5e30e84ad48af46fa78',
                     44:         'line' => 4
                     45:     },
                     46:     {   'text' => '(B) entry 5 is priority',
                     47:         'md5'  => 'c1692dfbf3b5829b6bce44b1a1614980',
                     48:         'line' => 5
                     49:     },
                     50:     {   'text' => 'entry 6 +delete',
                     51:         'md5'  => 'e1f6bf867f75aa019063782554407d02',
                     52:         'line' => 6
                     53:     }
                     54: ];
                     55:
                     56: my @list;
1.3     ! andrew     57: ok( @list = $api->get_list( $api->_todo), 'get_list' );
1.1       andrew     58: is( scalar @list, 6, 'list is right length' );
                     59: is_deeply( \@list, $list_should_be, 'check that we got the right list' );
1.3     ! andrew     60:
        !            61: foreach my $arg (
        !            62:     'todo_file', '/todo_file/list',
        !            63:     { path => '/todo_file/list' },
        !            64:     { list => 'todo_file', action => 'list', args => [] },
        !            65:     )
        !            66: {
        !            67:     my @list;
        !            68:     ok( @list = $api->GET($arg), "GET($arg)" );
        !            69:     is( scalar @list, 6, 'list is right length' );
        !            70:     is_deeply( \@list, $list_should_be, 'check that we got the right list' );
        !            71: }

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