X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2F2-input.t;h=1983bee1c9d7e65c2808fc6aa70e41be5a485b5a;hb=5d5fc808565b88bca0e2d10aa62bd89c7e748743;hp=19af3df067127db5bc4c3f18d1c0c6c7b79d50bd;hpb=083417bd66ab50058b5f57e1ee13146a369cfbd1;p=webpac2 diff --git a/t/2-input.t b/t/2-input.t index 19af3df..1983bee 100755 --- a/t/2-input.t +++ b/t/2-input.t @@ -1,31 +1,27 @@ #!/usr/bin/perl -w -use Test::More tests => 118; -use Test::Exception; -use Cwd qw/abs_path/; -use blib; use strict; +use blib; -use Data::Dump qw/dump/; +use Test::More tests => 124; BEGIN { +use_ok( 'WebPAC::Test' ); use_ok( 'WebPAC::Input::ISIS' ); use_ok( 'WebPAC::Input::MARC' ); use_ok( 'WebPAC::Input::Test' ); } -my $debug = shift @ARGV; -my $no_log = $debug ? 0 : 1; +$LOG{no_progress_bar} = 1; -ok(my $abs_path = abs_path($0), "abs_path"); -$abs_path =~ s#/[^/]*$#/#; +warn "# LOG = ",dump( %LOG ); my $module = 'WebPAC::Input::ISIS'; diag "testing with $module"; -throws_ok { my $input = new WebPAC::Input( ) } qr/module/, "need module"; -ok(my $input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, stats => 1 ), "new $module"); -ok(my $input_lm = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1 ), "new $module"); +throws_ok { my $input = new WebPAC::Input( %LOG ) } qr/module/, "need module"; +ok(my $input = new WebPAC::Input( module => $module, stats => 1, \%LOG ), "new $module"); +ok(my $input_lm = new WebPAC::Input( module => $module, \%LOG ), "new $module"); throws_ok { $input->open( ) } qr/path/, "need path"; @@ -79,6 +75,8 @@ sub test_fetch($$) { cmp_ok($input->pos, '==', $mfn, "pos $mfn"); push @db, $rec; ok(my $dump = $input->dump_ascii, "dump_ascii $mfn"); + # XXX test count will help us keep this test in-line :-) + ok($rec->{leader}, "leader $mfn") if $rec->{leader}; diag $dump if ($debug); } @@ -105,13 +103,13 @@ test_start_limit($input, $size, 3, 0); test_start_limit($input, 3, $size, $size - 2); test_start_limit($input, 1, $size + 2, $size); -ok(my $s = $input->stats, 'stats'); +ok(my $s = $input->stats, "$module stats"); diag "stats:\n$s" if ($debug); $module = 'WebPAC::Input::MARC'; diag "testing with $module"; -ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1 ), "new $module"); +ok($input = new WebPAC::Input( module => $module, stats => 1, %LOG ), "new $module"); ok($input->open( path => "$abs_path/data/marc.iso" ), "open marc.iso"); @@ -119,9 +117,12 @@ test_after_open($input); test_fetch($input, $input->size); +ok(my $s = $input->stats, "$module stats"); + +diag "stats:\n$s" if ($debug); # test modify_record $module = 'WebPAC::Input::Test'; -ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, debug => $debug ), "new $module"); +ok($input = new WebPAC::Input( module => $module, %LOG ), "new $module"); $WebPAC::Input::Test::rec = { '200' => [