/[webpac2]/trunk/t/5-output-swish.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/t/5-output-swish.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1145 - (hide annotations)
Thu Apr 23 11:14:24 2009 UTC (15 years ago) by dpavlin
File MIME type: application/x-troff
File size: 1451 byte(s)
 r1798@llin:  dpavlin | 2009-04-23 13:14:23 +0200
 start support for swish-e using WebPAC::Output::SWISH

1 dpavlin 1145 #!/usr/bin/perl -w
2    
3     use strict;
4     use blib;
5    
6     use Test::More tests => 35;
7    
8     BEGIN {
9     use_ok( 'WebPAC::Test' );
10     use_ok( 'WebPAC::Output::SWISH' );
11     use_ok( 'SWISH::API' );
12     }
13    
14     my $path = "$abs_path/kino/";
15    
16     ok(my $out = new WebPAC::Output::SWISH(
17     database => 'test',
18     %LOG
19     ), "new");
20    
21     my $ds = {
22     'Source' => {
23     'name' => 'Izvor: ',
24     'search' => [ 'tko zna' ]
25     },
26     'ID' => {
27     'search' => 'id',
28     },
29     'Array' => {
30     'search' => [ qw/a1 a2 s3 a4 a5/ ],
31     },
32     'foo' => {
33     'search' => [ 'foo' ],
34     },
35     };
36    
37     throws_ok { $out->add( ) } qr/need id/, 'add without params';
38     throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds';
39    
40     ok( $out->add( 42, $ds ), 'add 42' );
41    
42     my @strange = ( qw/èajðinica odma¹æivanje ¾abokreèina ¹uma/ );
43    
44     ok( $out->add( 99, { foo => { search => [ @strange ] } } ), 'add 99' );
45    
46     ok( $out->add( 100, { foo => { search => [ qw/foo bar baz/ ] } } ), 'add 100' );
47    
48     ok( $out->finish, 'finish' );
49    
50     sub test_search {
51     my ( $query_string, $expected_hits ) = @_;
52    
53     my $swish = SWISH::API->new( $out->index_path );
54     $swish->abort_last_error if $swish->Error;
55    
56     my $results = $swish->search( $query_string );
57    
58     my $total_hits = $results->hits;
59    
60     ok( $total_hits, "search '$query_string'" );
61    
62     diag "Total hits: $total_hits\n" if $debug;
63    
64     cmp_ok( $total_hits, '==', $expected_hits, 'total_hits' );
65    
66     while ( my $hit = $results->next_result ) {
67     diag dump($hit) if $debug;
68     }
69    
70     }
71    
72     test_search( 'foo', 2 );
73    
74     test_search( $_, 1 ) foreach @strange;
75    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26