[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.6

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.6     ! andrew     10: #     REVISION:  $AFresh1: list.t,v 1.5 2010/01/26 04:30:13 andrew Exp $
1.1       andrew     11: #===============================================================================
                     12:
                     13: use strict;
                     14: use warnings;
                     15:
1.6     ! andrew     16: use Test::More tests => 59;
1.1       andrew     17:
1.5       andrew     18: my $api_class;
1.1       andrew     19: my $class;
1.3       andrew     20:
1.1       andrew     21: BEGIN {
1.5       andrew     22:     $api_class = 'Text::Todo::REST::API';
                     23:     $class = 'Text::Todo::REST::API::Actions::GET';
                     24:
                     25:     use_ok( $api_class, "use $api_class" );
1.1       andrew     26:     use_ok( $class, "use $class" );
                     27: }
                     28:
1.5       andrew     29: diag("Testing GET list $class $Text::Todo::REST::API::Actions::GET::VERSION");
1.1       andrew     30:
1.5       andrew     31: my $api = new_ok( $api_class, [ { todo_dir => 't/lists' } ] );
                     32: my $action = new_ok($class);
1.1       andrew     33:
                     34: my $list_should_be = [
                     35:     {   'text' => '(A) entry 1 @one +uno',
                     36:         'md5'  => '931e0831c31a70928b29de55778dc294',
                     37:         'line' => 1
                     38:     },
                     39:     {   'text' => 'entry 2 @two +dos',
                     40:         'md5'  => 'b38dde8029c047e81379d9de581a6251',
                     41:         'line' => 2
                     42:     },
                     43:     {   'text' => '',
                     44:         'md5'  => 'd41d8cd98f00b204e9800998ecf8427e',
                     45:         'line' => 3
                     46:     },
                     47:     {   'text' => 'x completed entry 4',
                     48:         'md5'  => '8de0a2b65a50d5e30e84ad48af46fa78',
                     49:         'line' => 4
                     50:     },
                     51:     {   'text' => '(B) entry 5 is priority',
                     52:         'md5'  => 'c1692dfbf3b5829b6bce44b1a1614980',
                     53:         'line' => 5
                     54:     },
                     55:     {   'text' => 'entry 6 +delete',
                     56:         'md5'  => 'e1f6bf867f75aa019063782554407d02',
                     57:         'line' => 6
                     58:     }
                     59: ];
                     60:
1.4       andrew     61: my $list;
1.5       andrew     62: ok( $list = $action->get_list( $api->_todo ), 'get_list' );
                     63: is( scalar @{$list}, 6, 'list is right length' );
1.4       andrew     64: is_deeply( $list, $list_should_be, 'check that we got the right list' );
1.3       andrew     65:
                     66: foreach my $arg (
1.6     ! andrew     67:     { list => undef, action => 'list', args => [] },
        !            68:
1.3       andrew     69:     'todo_file', '/todo_file/list',
                     70:     { path => '/todo_file/list' },
                     71:     { list => 'todo_file', action => 'list', args => [] },
1.6     ! andrew     72:
        !            73:     'todo', '/todo/list',
        !            74:     { path => '/todo/list' },
        !            75:     { list => 'todo', action => 'list', args => [] },
        !            76:
        !            77:     'todo.txt', '/todo.txt/list',
        !            78:     { path => '/todo.txt/list' },
        !            79:     { list => 'todo.txt', action => 'list', args => [] },
1.3       andrew     80:     )
                     81: {
1.4       andrew     82:     my $response;
                     83:     ok( $response = $api->GET($arg), "GET($arg)" );
                     84:     my $list;
                     85:     ok( $list = $response->data, 'Get response data' );
1.5       andrew     86:     is( scalar @{$list}, 6, 'list is right length' );
1.4       andrew     87:     is_deeply( $list, $list_should_be, 'check that we got the right list' );
1.3       andrew     88: }

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