2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
use Test::More tests => 75; |
use Test::More tests => 93; |
6 |
use Test::Exception; |
use Test::Exception; |
7 |
use File::Temp qw/ :mktemp /; |
use File::Temp qw/ :mktemp /; |
8 |
use blib; |
use blib; |
19 |
|
|
20 |
my %param; |
my %param; |
21 |
|
|
22 |
throws_ok { SWISH::Split->open(%param) } qr/slice_name/, "slice_name"; |
throws_ok { SWISH::Split->open_index(%param) } qr/slice_name/, "slice_name"; |
23 |
|
|
24 |
sub slice_hash { |
sub slice_hash { |
25 |
return $_[0]; |
return $_[0]; |
26 |
}; |
}; |
27 |
|
|
28 |
$param{'slice_name'} = \&slice_hash; |
$param{'slice_name'} = \&slice_hash; |
29 |
throws_ok { SWISH::Split->open(%param) } qr/slices/, "need slices"; |
throws_ok { SWISH::Split->open_index(%param) } qr/slices/, "need slices"; |
30 |
|
|
31 |
$param{'slices'} = 3; |
$param{'slices'} = 3; |
32 |
throws_ok { SWISH::Split->open(%param) } qr/index/, "need index"; |
throws_ok { SWISH::Split->open_index(%param) } qr/index/, "need index"; |
33 |
|
|
34 |
ok($param{'index'} = mktemp("/tmp/swishXXXXX"), "index name"); |
ok($param{'index'} = mktemp("/tmp/swishXXXXX"), "index name"); |
35 |
|
|
38 |
ok(open(F, "> $param{'index'}"), "touch"); |
ok(open(F, "> $param{'index'}"), "touch"); |
39 |
close(F); |
close(F); |
40 |
|
|
41 |
throws_ok { SWISH::Split->open(%param) } qr/dir/, "need dir"; |
throws_ok { SWISH::Split->open_index(%param) } qr/dir/, "need dir"; |
42 |
|
|
43 |
ok(unlink($param{'index'}), "rm"); |
ok(unlink($param{'index'}), "rm"); |
44 |
|
|
48 |
PropertyNames foo |
PropertyNames foo |
49 |
}; |
}; |
50 |
|
|
51 |
ok(my $i=SWISH::Split->open(%param), "open"); |
$param{'debug'} = 1 if (@ARGV); |
52 |
|
|
53 |
cmp_ok(my $s = $i->in_slice("swishpath"), '==', 1, "open"); |
ok(my $i=SWISH::Split->open_index(%param), "open_index"); |
54 |
|
|
55 |
|
cmp_ok(my $s = $i->in_slice("swishpath"), '==', 1, "open_index"); |
56 |
|
|
57 |
ok(my $config = $i->make_config($s), "make_config"); |
ok(my $config = $i->make_config($s), "make_config"); |
58 |
diag "swish config: $config"; |
diag "swish config: $config"; |
140 |
cmp_ok($i->done, '==', 3, "finish"); |
cmp_ok($i->done, '==', 3, "finish"); |
141 |
|
|
142 |
foreach (1..$param{'slices'}) { |
foreach (1..$param{'slices'}) { |
143 |
swish_search( $param{'index'}."/$_", "foo=(bar*)", $slice_files{$_}, "testpath", length($xml)+4, "foo", "bar"); |
swish_search( $param{'index'}."/$_", "foo=(bar*)", $slice_files{$_}, "testpath", undef, "foo", "bar"); |
144 |
} |
} |
145 |
|
|
146 |
#diag "$out"; |
#diag "$out"; |