[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.6, Tue Jan 26 03:51:49 2010 UTC (14 years, 5 months ago) by andrew
Branch: MAIN
Changes since 1.5: +29 -68 lines

add get_entry_done method
Some cleanup of get_entry
pretty much rewrite t/GET/entry.t

#===============================================================================
#
#         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.6 2010/01/26 03:51:49 andrew Exp $
#===============================================================================

use strict;
use warnings;

use Test::More tests => 87;

my $class;

BEGIN {
    $class = 'Text::Todo::REST::API';
    use_ok( $class, "use $class" );
}

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

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

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 = $api->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' );
    }
}