Annotation of todotxt/Text-Todo-REST-API/t/GET/entry.t, Revision 1.8
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.8 ! andrew 10: # REVISION: $AFresh1: entry.t,v 1.7 2010/01/26 04:30:13 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.8 ! andrew 29: diag(
! 30: "Testing GET entry $class $Text::Todo::REST::API::Actions::GET::VERSION");
1.1 andrew 31:
1.7 andrew 32: my $api = new_ok( $api_class, [ { todo_dir => 't/lists' } ] );
1.8 ! andrew 33: my $action = new_ok($class);
1.1 andrew 34:
1.6 andrew 35: my $list_should_be;
36: ok( $list_should_be = $api->GET('todo_file'), 'Get todo_file' );
37:
38: my @types = ( 'line', 'md5' );
39:
40: foreach my $e ( @{ $list_should_be->data } ) {
41: foreach my $type (@types) {
42: my $entry;
1.7 andrew 43: ok( $entry = $action->get_entry( $api->_todo, $e->{$type} ),
1.6 andrew 44: "by $type get_entry($e->{$type})" );
45: is_deeply( $entry, $e, "Entry Matches" );
46:
47: my $response;
48: ok( $response = $api->GET( '/todo_file/entry/' . $e->{$type} ),
49: "by $type GET($e->{$type})" );
50: $entry = undef;
51: ok( $entry = $response->data, 'Get data from response' );
52: is_deeply( $entry, $e, "Entry Matches" );
53:
54: $response = undef;
55: ok( $response
56: = $api->GET( '/todo_file/entry/' . $e->{$type} . '/done' ),
57: "by $type GET($e->{$type}/done)"
58: );
59: my ($should_be) = $e->{text} =~ /^(x)/xms;
60: is( $response->data, $should_be, 'Check done status' );
1.1 andrew 61: }
1.6 andrew 62: }
1.1 andrew 63:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>