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

File: [local] / todotxt / Text-Todo-REST-API / t / GET / entry.t (download)

Revision 1.10, Sat Feb 13 21:48:28 2010 UTC (14 years, 4 months ago) by andrew
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +3 -3 lines

do need /file/action/identifier
cuZ I need to get /file/tags and /file/entry

#===============================================================================
#
#         FILE:  GET/entry.t
#
#  DESCRIPTION:  Test Text::Todo::REST::API
#
#       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org
#      COMPANY:  Red River Communications
#      CREATED:  01/07/10 19:11
#     REVISION:  $AFresh1: entry.t,v 1.10 2010/02/13 21:48:28 andrew Exp $
#===============================================================================

use strict;
use warnings;

use Test::More tests => 89;

my $api_class;
my $class;

BEGIN {
    $api_class = 'Text::Todo::REST::API';
    $class     = 'Text::Todo::REST::API::Actions::GET';

    use_ok( $api_class, "use $api_class" );
    use_ok( $class,     "use $class" );
}

diag(
    "Testing GET entry $class $Text::Todo::REST::API::Actions::GET::VERSION");

my $api = new_ok( $api_class, [ { todo_dir => 't/lists' } ] );
my $action = new_ok($class);

my $list_should_be;
ok( $list_should_be = $api->GET('todo_file'), 'Get todo_file' );

my @types = ( 'line', 'md5' );

foreach my $e ( @{ $list_should_be->data } ) {
    foreach my $type (@types) {
        my $entry;
        ok( $entry = $action->get_entry( $api->_todo, $e->{$type} ),
            "by $type get_entry($e->{$type})" );
        is_deeply( $entry, $e, "Entry Matches" );

        my $response;
        ok( $response = $api->GET( '/todo_file/entry/' . $e->{$type} ),
            "by $type GET($e->{$type})" );
        $entry = undef;
        ok( $entry = $response->data, 'Get data from response' );
        is_deeply( $entry, $e, "Entry Matches" );

        $response = undef;
        ok( $response
                = $api->GET( '/todo_file/entry/' . $e->{$type} . '/done' ),
            "by $type GET($e->{$type}/done)"
        );
        my ($should_be) = $e->{text} =~ /^(x)/xms;
        is( $response->data, $should_be, 'Check done status' );
    }
}