version 1.3, 2010/01/17 21:53:35 |
version 1.4, 2010/01/17 22:55:59 |
|
|
# AUTHOR: Andrew Fresh (AAF), andrew@cpan.org |
# AUTHOR: Andrew Fresh (AAF), andrew@cpan.org |
# COMPANY: Red River Communications |
# COMPANY: Red River Communications |
# CREATED: 01/07/10 19:11 |
# CREATED: 01/07/10 19:11 |
# REVISION: $AFresh1: text.t,v 1.2 2010/01/17 21:08:55 andrew Exp $ |
# REVISION: $AFresh1: text.t,v 1.3 2010/01/17 21:53:35 andrew Exp $ |
#=============================================================================== |
#=============================================================================== |
|
|
use strict; |
use strict; |
|
|
|
|
my $class; |
my $class; |
my $subclass; |
my $subclass; |
|
my $ext; |
|
|
BEGIN { |
BEGIN { |
|
$ext = 'txt'; |
|
|
$class = 'Text::Todo::REST::API'; |
$class = 'Text::Todo::REST::API'; |
use_ok( $class, "use $class" ); |
use_ok( $class, "use $class" ); |
|
|
|
|
use_ok( $subclass, "use $subclass" ); |
use_ok( $subclass, "use $subclass" ); |
} |
} |
|
|
diag("Testing entry $class $Text::Todo::REST::API::text::VERSION"); |
diag("Testing entry $subclass $Text::Todo::REST::API::text::VERSION"); |
|
|
my $api = new_ok( $class, |
my $api = new_ok( $class, |
[ { basedir => 't', path_info => '/lists/todo.txt' } ] ); |
[ { basedir => 't', path_info => '/lists/todo.' . $ext } ] ); |
isa_ok( $api, $subclass, 'isa ' . $subclass ); |
isa_ok( $api, $subclass ); |
|
|
my $list_should_be = [ |
my $list_should_be = [ |
{ 'text' => '(A) entry 1 @one +uno', |
{ 'text' => '(A) entry 1 @one +uno', |
|
|
like( $@, '/^Unable to Load \[list\]/', 'Failed Load as expected' ); |
like( $@, '/^Unable to Load \[list\]/', 'Failed Load as expected' ); |
|
|
$result = undef; |
$result = undef; |
ok( !( $result = $api->Dump()), 'Dump method' ); |
ok( !( $result = $api->Dump() ), 'Dump method' ); |
is($result, undef, 'Dump returned undef'); |
is( $result, undef, 'Dump returned undef' ); |
|
|
$result = undef; |
$result = undef; |
ok( eval { $result = $api->Dump( @{$list_should_be} ) }, |
ok( eval { $result = $api->Dump( @{$list_should_be} ) }, 'Dump method' ); |
'Dump method' ); |
|
is( $result, $list_dump_should_be, 'Got expected Dump result' ); |
is( $result, $list_dump_should_be, 'Got expected Dump result' ); |
$result = undef; |
$result = undef; |
|
|
|
|
my $api = new_ok( |
my $api = new_ok( |
$class, |
$class, |
[ { basedir => 't', |
[ { basedir => 't', |
path_info => '/lists/todo/entry/' . $e->{md5} . '.txt' |
path_info => '/lists/todo/entry/' . $e->{md5} . '.' . $ext |
} |
} |
] |
] |
); |
); |
my @entry; |
my @entry; |
ok( @entry = $api->GET(), "get_entry by GET()" ); |
ok( @entry = $api->GET(), "get_entry by GET()" ); |
is_deeply( \@entry, [ $e ], 'got correct entry' ); |
is_deeply( \@entry, [$e], 'got correct entry' ); |
|
|
my $result; |
my $result; |
ok( $result = $api->Dump(@entry), 'Dump output' ); |
ok( $result = $api->Dump(@entry), 'Dump output' ); |