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

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.6     ! andrew     10: #     REVISION:  $AFresh1: entry.t,v 1.5 2010/01/24 04:39:12 andrew Exp $
1.1       andrew     11: #===============================================================================
                     12:
                     13: use strict;
                     14: use warnings;
                     15:
1.6     ! andrew     16: use Test::More tests => 87;
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:
1.6     ! andrew     29: my $list_should_be;
        !            30: ok( $list_should_be = $api->GET('todo_file'), 'Get todo_file' );
        !            31:
        !            32: my @types = ( 'line', 'md5' );
        !            33:
        !            34: foreach my $e ( @{ $list_should_be->data } ) {
        !            35:     foreach my $type (@types) {
        !            36:         my $entry;
        !            37:         ok( $entry = $api->get_entry( $api->_todo, $e->{$type} ),
        !            38:             "by $type get_entry($e->{$type})" );
        !            39:         is_deeply( $entry, $e, "Entry Matches" );
        !            40:
        !            41:         my $response;
        !            42:         ok( $response = $api->GET( '/todo_file/entry/' . $e->{$type} ),
        !            43:             "by $type GET($e->{$type})" );
        !            44:         $entry = undef;
        !            45:         ok( $entry = $response->data, 'Get data from response' );
        !            46:         is_deeply( $entry, $e, "Entry Matches" );
        !            47:
        !            48:         $response = undef;
        !            49:         ok( $response
        !            50:                 = $api->GET( '/todo_file/entry/' . $e->{$type} . '/done' ),
        !            51:             "by $type GET($e->{$type}/done)"
        !            52:         );
        !            53:         my ($should_be) = $e->{text} =~ /^(x)/xms;
        !            54:         is( $response->data, $should_be, 'Check done status' );
1.1       andrew     55:     }
1.6     ! andrew     56: }
1.1       andrew     57:

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