[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.3

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

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