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

Annotation of todotxt/Text-Todo-REST-API/t/GET/entry.t, Revision 1.4

1.1       andrew      1: #===============================================================================
                      2: #
                      3: #         FILE:  GET/entry.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.4     ! andrew     10: #     REVISION:  $AFresh1: entry.t,v 1.3 2010/01/23 07:15:40 andrew Exp $
1.1       andrew     11: #===============================================================================
                     12:
                     13: use strict;
                     14: use warnings;
                     15:
1.3       andrew     16: use Test::More tests => 50;
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 entry $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: foreach my $e ( @{$list_should_be} ) {
                     57:     my $entry;
1.3       andrew     58:     ok( $entry = $api->get_entry( $api->_todo, $e->{line} ),
                     59:         "by line get_entry($e->{line})"
                     60:     );
                     61:     is_deeply( $entry, $e, 'got correct entry' );
                     62:
                     63:     $entry = undef;
                     64:     ok( $entry = $api->get_entry( $api->_todo, $e->{md5} ),
                     65:         "by md5 get_entry($e->{md5})"
                     66:     );
                     67:     is_deeply( $entry, $e, 'got correct entry' );
                     68:
1.4     ! andrew     69:     my $response;
        !            70:     ok( $response = $api->GET( '/todo_file/entry/' . $e->{line} ),
1.3       andrew     71:         "by line GET($e->{line})"
1.1       andrew     72:     );
1.4     ! andrew     73:     $entry = undef;
        !            74:     ok( $entry = $response->data, 'Get data from response' );
1.1       andrew     75:     is_deeply( $entry, $e, 'got correct entry' );
                     76:
1.4     ! andrew     77:     $response = undef;
        !            78:     ok( $response = $api->GET( '/todo_file/entry/' . $e->{md5} ),
1.3       andrew     79:         "by md5 GET($e->{md5})"
1.1       andrew     80:     );
1.4     ! andrew     81:     $entry = undef;
        !            82:     ok( $entry = $response->data, 'Get data from response' );
1.1       andrew     83:     is_deeply( $entry, $e, 'got correct entry' );
                     84:
1.3       andrew     85: #    $entry = undef;
                     86: #    ok( $entry = $api->GET( '/todo_file/entry/' . $e->{line} . '/done' ),
                     87: #        "by line GET($e->{line}/done)"
                     88: #    );
                     89: #    is_deeply( $entry, $e, 'got correct entry' );
                     90:
                     91: #    $entry = undef;
                     92: #    ok( $entry = $api->GET( '/todo_file/entry/' . $e->{md5} . '/done' ),
                     93: #        "by md5 GET($e->{md5}/done)"
                     94: #    );
                     95: #    is_deeply( $entry, $e, 'got correct entry' );
1.1       andrew     96: }

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