File: 001Basic.t

package info (click to toggle)
libswish-api-common-perl 0.04-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 229; makefile: 2
file content (61 lines) | stat: -rw-r--r-- 1,760 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
######################################################################
# Test suite for SWISH::API::Common
# by Mike Schilli <cpan@perlmeister.com>
######################################################################

use warnings;
use strict;

use Test::More qw(no_plan);
use Sysadm::Install qw(:all);
use Log::Log4perl qw(:easy);
#Log::Log4perl->easy_init($DEBUG);

BEGIN { use_ok('SWISH::API::Common') };

my $CANNED = "eg/canned";
$CANNED = "../eg/canned" unless -d $CANNED;

use SWISH::API::Common;

my $sw = SWISH::API::Common->new(
  swish_adm_dir             => "$CANNED/adm",
  swish_fuzzy_indexing_mode => "NONE",
);
$sw->index("$CANNED/data1");

my @found = $sw->search("mike");
my $found = join " ", map { $_->path } @found;
like($found, qr(canned/data1/abc), "simple query");

@found = $sw->search("someone AND else");
$found = join " ", map { $_->path } @found;
like($found, qr(canned/data1/def), "boolean query");

@found = $sw->search("someone AND else OR mike");
$found = join " ", map { $_->path } @found;
like($found, qr(canned/data1/def), "and-or query");
like($found, qr(canned/data1/abc), "and-or query");

    # Two directories
$sw->index_remove();

$sw = SWISH::API::Common->new(
  swish_adm_dir             => "$CANNED/adm",
  swish_fuzzy_indexing_mode => "NONE",
);
$sw->index("$CANNED/data1", "$CANNED/data2");

@found = $sw->search("mike");
$found = join " ", map { $_->path } @found;
like($found, qr(canned/data1/abc), "simple query (two dirs)");

@found = $sw->search("different");
$found = join " ", map { $_->path } @found;
like($found, qr(canned/data2/ghi), "simple query (two dirs)");

@found = $sw->search("nowhere");
$found = join " ", map { $_->path } @found;
is($found, "", "nothing found");

END { rmf "$CANNED/adm"; }