Annotation of todotxt/Text-Todo-REST-API/t/formats/text.t, Revision 1.3
1.1 andrew 1: #===============================================================================
2: #
3: # FILE: text.t
4: #
5: # DESCRIPTION: Test Text::Todo::REST::API::text
6: #
7: # AUTHOR: Andrew Fresh (AAF), andrew@cpan.org
8: # COMPANY: Red River Communications
9: # CREATED: 01/07/10 19:11
1.3 ! andrew 10: # REVISION: $AFresh1: text.t,v 1.2 2010/01/17 21:08:55 andrew Exp $
1.1 andrew 11: #===============================================================================
12:
13: use strict;
14: use warnings;
15:
1.3 ! andrew 16: use Test::More tests => 40;
1.1 andrew 17:
18: my $class;
19: my $subclass;
20:
21: BEGIN {
22: $class = 'Text::Todo::REST::API';
23: use_ok( $class, "use $class" );
24:
25: $subclass = $class . '::text';
26: use_ok( $subclass, "use $subclass" );
27: }
28:
29: diag("Testing entry $class $Text::Todo::REST::API::text::VERSION");
30:
31: my $api = new_ok( $class,
32: [ { basedir => 't', path_info => '/lists/todo.txt' } ] );
33: isa_ok( $api, $subclass, 'isa ' . $subclass );
34:
35: my $list_should_be = [
36: { 'text' => '(A) entry 1 @one +uno',
37: 'md5' => '931e0831c31a70928b29de55778dc294',
38: 'line' => 1
39: },
40: { 'text' => 'entry 2 @two +dos',
41: 'md5' => 'b38dde8029c047e81379d9de581a6251',
42: 'line' => 2
43: },
44: { 'text' => '',
45: 'md5' => 'd41d8cd98f00b204e9800998ecf8427e',
46: 'line' => 3
47: },
48: { 'text' => 'x completed entry 4',
49: 'md5' => '8de0a2b65a50d5e30e84ad48af46fa78',
50: 'line' => 4
51: },
52: { 'text' => '(B) entry 5 is priority',
53: 'md5' => 'c1692dfbf3b5829b6bce44b1a1614980',
54: 'line' => 5
55: },
56: { 'text' => 'entry 6 +delete',
57: 'md5' => 'e1f6bf867f75aa019063782554407d02',
58: 'line' => 6
59: }
60: ];
61:
62: my $list_dump_should_be = join q{},
63: map { $_->{text} . "\n" } @{$list_should_be};
64:
65: my $result;
1.3 ! andrew 66: ok( !eval { $result = $api->Load() }, 'Load method' );
! 67: like( $@, '/^Unable to Load \[list\]/', 'Failed Load as expected' );
1.1 andrew 68:
69: $result = undef;
1.3 ! andrew 70: ok( !( $result = $api->Dump()), 'Dump method' );
! 71: is($result, undef, 'Dump returned undef');
1.1 andrew 72:
73: $result = undef;
1.3 ! andrew 74: ok( eval { $result = $api->Dump( @{$list_should_be} ) },
1.1 andrew 75: 'Dump method' );
76: is( $result, $list_dump_should_be, 'Got expected Dump result' );
77: $result = undef;
1.2 andrew 78:
79: foreach my $e ( @{$list_should_be} ) {
80: my $api = new_ok(
81: $class,
82: [ { basedir => 't',
83: path_info => '/lists/todo/entry/' . $e->{md5} . '.txt'
84: }
85: ]
86: );
1.3 ! andrew 87: my @entry;
! 88: ok( @entry = $api->GET(), "get_entry by GET()" );
! 89: is_deeply( \@entry, [ $e ], 'got correct entry' );
! 90:
! 91: my $result;
! 92: ok( $result = $api->Dump(@entry), 'Dump output' );
! 93: is( $result, $e->{text} . "\n", 'Got correct Dump result' );
1.2 andrew 94: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>