Annotation of todotxt/Text-Todo-REST-API/t/GET/list.t, Revision 1.5
1.1 andrew 1: #===============================================================================
2: #
3: # FILE: GET/list.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.5 ! andrew 10: # REVISION: $AFresh1: list.t,v 1.4 2010/01/24 04:38:21 andrew Exp $
1.1 andrew 11: #===============================================================================
12:
13: use strict;
14: use warnings;
15:
1.5 ! andrew 16: use Test::More tests => 23;
1.1 andrew 17:
1.5 ! andrew 18: my $api_class;
1.1 andrew 19: my $class;
1.3 andrew 20:
1.1 andrew 21: BEGIN {
1.5 ! 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" );
1.1 andrew 26: use_ok( $class, "use $class" );
27: }
28:
1.5 ! andrew 29: diag("Testing GET list $class $Text::Todo::REST::API::Actions::GET::VERSION");
1.1 andrew 30:
1.5 ! andrew 31: my $api = new_ok( $api_class, [ { todo_dir => 't/lists' } ] );
! 32: my $action = new_ok($class);
1.1 andrew 33:
34: my $list_should_be = [
35: { 'text' => '(A) entry 1 @one +uno',
36: 'md5' => '931e0831c31a70928b29de55778dc294',
37: 'line' => 1
38: },
39: { 'text' => 'entry 2 @two +dos',
40: 'md5' => 'b38dde8029c047e81379d9de581a6251',
41: 'line' => 2
42: },
43: { 'text' => '',
44: 'md5' => 'd41d8cd98f00b204e9800998ecf8427e',
45: 'line' => 3
46: },
47: { 'text' => 'x completed entry 4',
48: 'md5' => '8de0a2b65a50d5e30e84ad48af46fa78',
49: 'line' => 4
50: },
51: { 'text' => '(B) entry 5 is priority',
52: 'md5' => 'c1692dfbf3b5829b6bce44b1a1614980',
53: 'line' => 5
54: },
55: { 'text' => 'entry 6 +delete',
56: 'md5' => 'e1f6bf867f75aa019063782554407d02',
57: 'line' => 6
58: }
59: ];
60:
1.4 andrew 61: my $list;
1.5 ! andrew 62: ok( $list = $action->get_list( $api->_todo ), 'get_list' );
! 63: is( scalar @{$list}, 6, 'list is right length' );
1.4 andrew 64: is_deeply( $list, $list_should_be, 'check that we got the right list' );
1.3 andrew 65:
66: foreach my $arg (
67: 'todo_file', '/todo_file/list',
68: { path => '/todo_file/list' },
69: { list => 'todo_file', action => 'list', args => [] },
70: )
71: {
1.4 andrew 72: my $response;
73: ok( $response = $api->GET($arg), "GET($arg)" );
74: my $list;
75: ok( $list = $response->data, 'Get response data' );
1.5 ! andrew 76: is( scalar @{$list}, 6, 'list is right length' );
1.4 andrew 77: is_deeply( $list, $list_should_be, 'check that we got the right list' );
1.3 andrew 78: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>