2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
use Test::More tests => 25; |
use Test::More tests => 33; |
6 |
|
|
7 |
BEGIN { |
BEGIN { |
8 |
use_ok('DBI'); |
use_ok('DBI'); |
46 |
|
|
47 |
sub estcmd { |
sub estcmd { |
48 |
my $q = shift; |
my $q = shift; |
49 |
|
my $attr = shift; |
50 |
|
|
51 |
my $cmd = "estcmd search $index '$q'"; |
my $cmd = "estcmd search "; |
52 |
|
$cmd .= " -attr '$attr' " if ($attr); |
53 |
|
$q ||= ''; |
54 |
|
$cmd .= "$index '$q'"; |
55 |
diag $cmd; |
diag $cmd; |
56 |
|
|
57 |
open(my $fh, "$cmd |") || die "cmd: $!"; |
open(my $fh, "$cmd |") || die "cmd: $!"; |
63 |
return undef; |
return undef; |
64 |
} |
} |
65 |
|
|
66 |
foreach my $q (qw(blade runner Philip filip dick)) { |
# test simple query |
67 |
|
foreach my $q (qw(blade runner Philip k. dick)) { |
68 |
|
|
69 |
ok(my $hits = estcmd($q), "estcmd: $q"); |
ok(my $hits = estcmd($q), "estcmd: $q"); |
70 |
|
|
72 |
|
|
73 |
cmp_ok(scalar pgest($q, '', 0, 0), '==', $hits, 'blade runner'); |
cmp_ok(scalar pgest($q, '', 0, 0), '==', $hits, 'blade runner'); |
74 |
} |
} |
75 |
|
|
76 |
|
# test attr query |
77 |
|
foreach my $q (('@title STRINC Blade Runner', '@title ISTRBW blade runner')) { |
78 |
|
|
79 |
|
ok(my $hits = estcmd('',$q), "estcmd: $q"); |
80 |
|
|
81 |
|
diag "$hits hits"; |
82 |
|
|
83 |
|
cmp_ok(scalar pgest('', $q, 0, 0), '==', $hits, 'blade runner'); |
84 |
|
} |
85 |
|
|