/[SWISH-PlusPlus]/trunk/t/01swish.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/01swish.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (hide annotations)
Sun Dec 5 15:35:53 2004 UTC (19 years, 4 months ago) by dpavlin
Original Path: trunk/t/swish.t
File MIME type: application/x-troff
File size: 1752 byte(s)
store cwd in $i->{'cwd'}, store just version numbers in $i->{'version'},
_init_indexer doesn't mess with cwd while indexing, _index_fh is now private.

1 dpavlin 2 #!/usr/bin/perl -w
2    
3     use strict;
4    
5 dpavlin 14 use Test::More tests => 29;
6 dpavlin 2 use Test::Exception;
7 dpavlin 9 use lib '.';
8 dpavlin 2 use blib;
9    
10     BEGIN {
11     use_ok('SWISH::PlusPlus')
12     };
13    
14     my $i;
15    
16 dpavlin 10 throws_ok { SWISH::PlusPlus->new() } qr/index_dir/, "need index_dir";
17 dpavlin 2
18     ## FIXME
19     my $index = '/tmp/swish-pp';
20    
21 dpavlin 10 $i = SWISH::PlusPlus->new(
22 dpavlin 3 index_dir => $index,
23 dpavlin 8 debug => 0,
24 dpavlin 9 meta_in_body => 1,
25 dpavlin 3 );
26     ok($i, "open index");
27 dpavlin 2
28     ok(-e $index, "index exist");
29 dpavlin 3
30 dpavlin 14 ok($i->{'cwd'}, "cwd ".$i->{'cwd'});
31    
32 dpavlin 3 ok($i->check_bin, "swish++ check");
33    
34 dpavlin 14 ok($i->{'version'}, "version ".$i->{'version'});
35 dpavlin 4
36     ok($i->index_document( 42 => 'meaning of life' ), "index 42");
37    
38 dpavlin 9 ok($i->add(
39     path => 'life',
40     title => 'Ultimate question answer found here',
41 dpavlin 11 body => '42 is answer to all questions',
42     meta => {
43     author => 'Dobrica Pavlinusic',
44     date => '2004-12-05',
45     comment => 'woow!',
46     },
47 dpavlin 9 ), "index life");
48    
49 dpavlin 4 # add one dummy document so that swish++ won't reject all words
50     # with index of just one document
51     ok($i->index_document( _dummy_ => '' ), "fillter");
52 dpavlin 7
53     cmp_ok($i->{'index_dir'}, 'eq', $index, "index_dir ok");
54 dpavlin 8
55 dpavlin 14 # I would rather test search to close it itself!
56     #$i->finish_update;
57    
58 dpavlin 8 foreach my $word (qw(meaning of life)) {
59     my @r = $i->search($word);
60     cmp_ok(scalar @r, '==', 1, "find $word");
61     }
62 dpavlin 9
63     foreach my $word (qw(Ultimate question answer found here)) {
64     cmp_ok(scalar $i->search("title=($word)"), '==', 1, "find $word in title");
65     cmp_ok(scalar $i->search("$word"), '==', 1, "find $word anywhere");
66     }
67 dpavlin 11
68     foreach my $word (qw(Dobrica Pavlinusic)) {
69     cmp_ok(scalar $i->search("author=($word)"), '==', 1, "find $word in author");
70     }
71    
72     cmp_ok(scalar $i->search("date=2004-12-05"), '==', 1, "found date");
73    
74     cmp_ok(scalar $i->search("woow!"), '==', 1, "found woow");
75     cmp_ok(scalar $i->search("comment=(woow)"), '==', 1, "found woow");

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26