1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
|
use Test::More tests => 123; |
|
|
use Test::Exception; |
|
|
use Cwd qw/abs_path/; |
|
|
use blib; |
|
3 |
use strict; |
use strict; |
4 |
|
use lib 'lib'; |
5 |
|
|
6 |
use Data::Dump qw/dump/; |
use Test::More tests => 124; |
7 |
|
|
8 |
BEGIN { |
BEGIN { |
9 |
|
use_ok( 'WebPAC::Test' ); |
10 |
use_ok( 'WebPAC::Input::ISIS' ); |
use_ok( 'WebPAC::Input::ISIS' ); |
11 |
use_ok( 'WebPAC::Input::MARC' ); |
use_ok( 'WebPAC::Input::MARC' ); |
12 |
use_ok( 'WebPAC::Input::Test' ); |
use_ok( 'WebPAC::Input::Test' ); |
13 |
} |
} |
14 |
|
|
15 |
my $debug = shift @ARGV; |
$LOG{no_progress_bar} = 1; |
|
my $no_log = $debug ? 0 : 1; |
|
16 |
|
|
17 |
ok(my $abs_path = abs_path($0), "abs_path"); |
warn "# LOG = ",dump( %LOG ); |
|
$abs_path =~ s#/[^/]*$#/#; #vim |
|
18 |
|
|
19 |
my $module = 'WebPAC::Input::ISIS'; |
my $module = 'WebPAC::Input::ISIS'; |
20 |
diag "testing with $module"; |
diag "testing with $module"; |
21 |
|
|
22 |
throws_ok { my $input = new WebPAC::Input( no_log => $no_log ) } qr/module/, "need module"; |
throws_ok { my $input = new WebPAC::Input( %LOG ) } qr/module/, "need module"; |
23 |
ok(my $input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, stats => 1 ), "new $module"); |
ok(my $input = new WebPAC::Input( module => $module, stats => 1, \%LOG ), "new $module"); |
24 |
ok(my $input_lm = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1 ), "new $module"); |
ok(my $input_lm = new WebPAC::Input( module => $module, \%LOG ), "new $module"); |
25 |
|
|
26 |
throws_ok { $input->open( ) } qr/path/, "need path"; |
throws_ok { $input->open( ) } qr/path/, "need path"; |
27 |
|
|
94 |
diag "offset $s, limit: $l, expected: $e"; |
diag "offset $s, limit: $l, expected: $e"; |
95 |
|
|
96 |
ok($s = $input->open( path => "$abs_path/winisis/BIBL", offset => $s, limit => $l, debug => $debug ), "open winisis"); |
ok($s = $input->open( path => "$abs_path/winisis/BIBL", offset => $s, limit => $l, debug => $debug ), "open winisis"); |
97 |
cmp_ok($s, '==', $size, "db size from open = $size"); |
cmp_ok($s, '==', $size, "db size"); |
98 |
cmp_ok($input->size, '==', $e, "input->size = $e"); |
cmp_ok($input->size, '==', $e, "input->size = $e"); |
99 |
} |
} |
100 |
|
|
101 |
test_start_limit($input, 1, 3, 3); |
test_start_limit($input, 1, 3, 3); |
102 |
test_start_limit($input, $size, 3, 0); |
test_start_limit($input, $size, 3, 0); |
103 |
test_start_limit($input, 3, $size, $size - 2); |
test_start_limit($input, 3, $size, $size - 3); |
104 |
test_start_limit($input, 1, $size + 2, $size); |
test_start_limit($input, 1, $size, $size - 1); |
105 |
|
|
106 |
ok(my $s = $input->stats, 'stats'); |
ok(my $s = $input->stats, "$module stats"); |
107 |
diag "stats:\n$s" if ($debug); |
diag "stats:\n$s" if ($debug); |
108 |
|
|
109 |
$module = 'WebPAC::Input::MARC'; |
$module = 'WebPAC::Input::MARC'; |
110 |
diag "testing with $module"; |
diag "testing with $module"; |
111 |
|
|
112 |
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"); |
113 |
|
|
114 |
ok($input->open( path => "$abs_path/data/marc.iso" ), "open marc.iso"); |
ok($input->open( path => "$abs_path/data/marc.iso" ), "open marc.iso"); |
115 |
|
|
117 |
|
|
118 |
test_fetch($input, $input->size); |
test_fetch($input, $input->size); |
119 |
|
|
120 |
|
ok(my $s = $input->stats, "$module stats"); |
121 |
|
|
122 |
|
diag "stats:\n$s" if ($debug); |
123 |
# test modify_record |
# test modify_record |
124 |
$module = 'WebPAC::Input::Test'; |
$module = 'WebPAC::Input::Test'; |
125 |
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"); |
126 |
|
|
127 |
$WebPAC::Input::Test::rec = { |
$WebPAC::Input::Test::rec = { |
128 |
'200' => [ |
'200' => [ |