3 use Test::More tests => 20;
8 use Data::Dump qw/dump/;
13 use_ok( 'WebPAC::Output::KinoSearch' );
16 my $debug = shift @ARGV;
18 ok(my $abs_path = abs_path($0), "abs_path");
19 $abs_path =~ s#/[^/]*$#/#; #
20 diag "abs_path: $abs_path";
21 my $path = "$abs_path/kino/";
23 ok(my $out = new WebPAC::Output::KinoSearch({
30 ok( $out->init, 'init' );
41 'search' => [ qw/a1 a2 s3 a4 a5/ ],
45 throws_ok { $out->add( ) } qr/need id/, 'add without params';
46 throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds';
48 ok( $out->add( 42, $ds ), 'add 42' );
50 ok( $out->add( 99, { foo => { search => 'bar' } } ), 'add 99' );
52 ok( $out->add( 100, { foo => { search => [ qw/foo bar baz/ ] } } ), 'add 100' );
54 ok( -e $out->path, "created $path" );
56 ok( my $index = $out->index, 'have index' );
58 diag $out->path," eq ",$path;
59 cmp_ok( $out->path, 'eq', $path, 'path' );
61 my $query_string = 'foo';
63 my $total_hits = $index->search(
64 query => $query_string,
69 diag "Total hits: $total_hits\n";
70 while ( my $hit = $index->fetch_hit_hashref ) {
75 ok( $out->finish, 'finish' );