[BACK]Return to md5.t CVS log [TXT][DIR] Up to [local] / todotxt / Text-Todo-REST-API / t / formats

Annotation of todotxt/Text-Todo-REST-API/t/formats/md5.t, Revision 1.4

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>