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

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.7     ! andrew     10: #     REVISION:  $AFresh1: entry.t,v 1.6 2010/01/26 03:51:49 andrew Exp $
1.1       andrew     11: #===============================================================================
                     12:
                     13: use strict;
                     14: use warnings;
                     15:
1.7     ! andrew     16: use Test::More tests => 89;
1.1       andrew     17:
1.7     ! andrew     18: my $api_class;
1.1       andrew     19: my $class;
1.3       andrew     20:
1.1       andrew     21: BEGIN {
1.7     ! 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" );
        !            26:     use_ok( $class,     "use $class" );
1.1       andrew     27: }
                     28:
1.7     ! andrew     29: diag("Testing GET entry $class $Text::Todo::REST::API::Actions::GET::VERSION");
1.1       andrew     30:
1.7     ! andrew     31: my $api = new_ok( $api_class, [ { todo_dir => 't/lists' } ] );
        !            32: my $action = new_ok( $class );
1.1       andrew     33:
1.6       andrew     34: my $list_should_be;
                     35: ok( $list_should_be = $api->GET('todo_file'), 'Get todo_file' );
                     36:
                     37: my @types = ( 'line', 'md5' );
                     38:
                     39: foreach my $e ( @{ $list_should_be->data } ) {
                     40:     foreach my $type (@types) {
                     41:         my $entry;
1.7     ! andrew     42:         ok( $entry = $action->get_entry( $api->_todo, $e->{$type} ),
1.6       andrew     43:             "by $type get_entry($e->{$type})" );
                     44:         is_deeply( $entry, $e, "Entry Matches" );
                     45:
                     46:         my $response;
                     47:         ok( $response = $api->GET( '/todo_file/entry/' . $e->{$type} ),
                     48:             "by $type GET($e->{$type})" );
                     49:         $entry = undef;
                     50:         ok( $entry = $response->data, 'Get data from response' );
                     51:         is_deeply( $entry, $e, "Entry Matches" );
                     52:
                     53:         $response = undef;
                     54:         ok( $response
                     55:                 = $api->GET( '/todo_file/entry/' . $e->{$type} . '/done' ),
                     56:             "by $type GET($e->{$type}/done)"
                     57:         );
                     58:         my ($should_be) = $e->{text} =~ /^(x)/xms;
                     59:         is( $response->data, $should_be, 'Check done status' );
1.1       andrew     60:     }
1.6       andrew     61: }
1.1       andrew     62:

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