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