#===============================================================================
#
# 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.7 2010/01/26 04:30:13 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' );
}
}