Annotation of todotxt/Text-Todo-REST-API/t/GET/list.t, Revision 1.9
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.9 ! andrew 10: # REVISION: $AFresh1: list.t,v 1.8 2010/01/31 03:10:39 andrew Exp $
1.1 andrew 11: #===============================================================================
12:
13: use strict;
14: use warnings;
15:
1.6 andrew 16: use Test::More tests => 59;
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';
1.7 andrew 23: $class = 'Text::Todo::REST::API::Actions::GET';
1.5 andrew 24:
25: use_ok( $api_class, "use $api_class" );
1.7 andrew 26: use_ok( $class, "use $class" );
1.1 andrew 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',
1.9 ! andrew 37: 'line' => 1,
! 38: 'done' => undef,
1.1 andrew 39: },
40: { 'text' => 'entry 2 @two +dos',
41: 'md5' => 'b38dde8029c047e81379d9de581a6251',
1.9 ! andrew 42: 'line' => 2,
! 43: 'done' => undef,
1.1 andrew 44: },
45: { 'text' => '',
46: 'md5' => 'd41d8cd98f00b204e9800998ecf8427e',
1.9 ! andrew 47: 'line' => 3,
! 48: 'done' => undef,
1.1 andrew 49: },
50: { 'text' => 'x completed entry 4',
51: 'md5' => '8de0a2b65a50d5e30e84ad48af46fa78',
1.9 ! andrew 52: 'line' => 4,
! 53: 'done' => 'x',
1.1 andrew 54: },
55: { 'text' => '(B) entry 5 is priority',
56: 'md5' => 'c1692dfbf3b5829b6bce44b1a1614980',
1.9 ! andrew 57: 'line' => 5,
! 58: 'done' => undef,
1.1 andrew 59: },
60: { 'text' => 'entry 6 +delete',
61: 'md5' => 'e1f6bf867f75aa019063782554407d02',
1.9 ! andrew 62: 'line' => 6,
! 63: 'done' => undef,
1.1 andrew 64: }
65: ];
66:
1.4 andrew 67: my $list;
1.5 andrew 68: ok( $list = $action->get_list( $api->_todo ), 'get_list' );
69: is( scalar @{$list}, 6, 'list is right length' );
1.4 andrew 70: is_deeply( $list, $list_should_be, 'check that we got the right list' );
1.3 andrew 71:
72: foreach my $arg (
1.6 andrew 73: { list => undef, action => 'list', args => [] },
74:
1.8 andrew 75: 'todo_file', '/todo_file/',
76: { path => '/todo_file/' },
1.3 andrew 77: { list => 'todo_file', action => 'list', args => [] },
1.6 andrew 78:
1.8 andrew 79: 'todo', '/todo/',
80: { path => '/todo/' },
1.6 andrew 81: { list => 'todo', action => 'list', args => [] },
82:
1.8 andrew 83: 'todo.txt', '/todo.txt/',
84: { path => '/todo.txt/' },
1.6 andrew 85: { list => 'todo.txt', action => 'list', args => [] },
1.3 andrew 86: )
87: {
1.4 andrew 88: my $response;
89: ok( $response = $api->GET($arg), "GET($arg)" );
90: my $list;
91: ok( $list = $response->data, 'Get response data' );
1.5 andrew 92: is( scalar @{$list}, 6, 'list is right length' );
1.4 andrew 93: is_deeply( $list, $list_should_be, 'check that we got the right list' );
1.3 andrew 94: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>