Annotation of todotxt/Text-Todo-REST-API/t/formats/text.t, Revision 1.1
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
! 10: # REVISION: $AFresh1$
! 11: #===============================================================================
! 12:
! 13: use strict;
! 14: use warnings;
! 15:
! 16: use Test::More tests => 10;
! 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;
! 66: ok( !eval { $result = $api->Load('test') }, 'Load method (test)' );
! 67: like( $@, '/^Unable to Load \[test\]/', 'Failed Load as expected' );
! 68:
! 69: $result = undef;
! 70: ok( !eval { $result = $api->Dump('test') }, 'Dump method (test)' );
! 71: like( $@, '/^Unable to Dump \[test\]/', 'Failed Dump test as expected' );
! 72:
! 73: $result = undef;
! 74: ok( eval { $result = $api->Dump( 'list', @{$list_should_be} ) },
! 75: 'Dump method' );
! 76: is( $result, $list_dump_should_be, 'Got expected Dump result' );
! 77: $result = undef;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>