/[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 1256 - (hide annotations)
Tue Jul 28 12:40:46 2009 UTC (14 years, 10 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1383 byte(s)
use code from lib insted of blib

1 dpavlin 1145 #!/usr/bin/perl -w
2    
3     use strict;
4 dpavlin 1256 use lib 'lib';
5 dpavlin 1145
6     use Test::More tests => 35;
7    
8     BEGIN {
9 dpavlin 1147 use lib 'lib';
10     use_ok( 'WebPAC::Test' );
11     use_ok( 'WebPAC::Output::SWISH' );
12     use_ok( 'SWISH::API' );
13 dpavlin 1145 }
14    
15     my $path = "$abs_path/kino/";
16    
17 dpavlin 1147 ok(my $out = new WebPAC::Output::SWISH({
18 dpavlin 1145 database => 'test',
19     %LOG
20 dpavlin 1147 }), "new");
21 dpavlin 1145
22 dpavlin 1147 ok( $out->init, 'init' );
23    
24 dpavlin 1145 my $ds = {
25     'Source' => {
26     'name' => 'Izvor: ',
27     'search' => [ 'tko zna' ]
28     },
29     'ID' => {
30 dpavlin 1147 'search' => [ 'id' ],
31 dpavlin 1145 },
32     'Array' => {
33     'search' => [ qw/a1 a2 s3 a4 a5/ ],
34     },
35     'foo' => {
36     'search' => [ 'foo' ],
37     },
38     };
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 dpavlin 1147 my $results = $swish->query( $query_string );
57 dpavlin 1145
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