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

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.3     ! andrew     10: #     REVISION:  $AFresh1: entry.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 => 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:
        !            69:     $entry = undef;
        !            70:     ok( $entry = $api->GET( '/todo_file/entry/' . $e->{line} ),
        !            71:         "by line GET($e->{line})"
1.1       andrew     72:     );
                     73:     is_deeply( $entry, $e, 'got correct entry' );
                     74:
                     75:     $entry = undef;
1.3     ! andrew     76:     ok( $entry = $api->GET( '/todo_file/entry/' . $e->{md5} ),
        !            77:         "by md5 GET($e->{md5})"
1.1       andrew     78:     );
                     79:     is_deeply( $entry, $e, 'got correct entry' );
                     80:
1.3     ! andrew     81: #    $entry = undef;
        !            82: #    ok( $entry = $api->GET( '/todo_file/entry/' . $e->{line} . '/done' ),
        !            83: #        "by line GET($e->{line}/done)"
        !            84: #    );
        !            85: #    is_deeply( $entry, $e, 'got correct entry' );
        !            86:
        !            87: #    $entry = undef;
        !            88: #    ok( $entry = $api->GET( '/todo_file/entry/' . $e->{md5} . '/done' ),
        !            89: #        "by md5 GET($e->{md5}/done)"
        !            90: #    );
        !            91: #    is_deeply( $entry, $e, 'got correct entry' );
1.1       andrew     92: }

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