/[pgestraier]/trunk/t/pgest.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/pgest.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Fri May 20 22:09:16 2005 UTC (18 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1160 byte(s)
tests, some of which fail (which is whole point of having tests, I guess)

1 dpavlin 8 #!/usr/bin/perl -w
2    
3     use strict;
4    
5     use Test::More tests => 25;
6    
7     BEGIN {
8     use_ok('DBI');
9     use_ok('DBD::Pg');
10     };
11    
12     # hum?
13     my $connect = "DBI:Pg:dbname=test";
14    
15     my $dbh = DBI->connect($connect,"","") || die $DBI::errstr;
16     ok($dbh, "dbh");
17    
18     my $pwd = $0;
19     $pwd =~ s#/[^/]*$##;
20     if ($pwd !~ m#^/#) {
21     my $cwd = `pwd`;
22     chomp($cwd);
23     $pwd = $cwd . '/' . $pwd;
24     }
25     ok($pwd, "pwd: $pwd");
26     my $index = "$pwd/../data/casket/";
27    
28     my $sql = "select * from pgest('$index',?,?,?,?)";
29     diag "$sql";
30    
31     my $sth = $dbh->prepare($sql) || die $dbh->errstr();
32     ok($sth, "sth");
33    
34     sub pgest {
35     $sth->execute(@_) || die $sth->errstr();
36     ok($sth, "execute(".join(",",@_).")");
37    
38     my @arr;
39     while (my $row = $sth->fetchrow_hashref() ) {
40     push @arr, $row;
41     }
42     ok(@arr, "results ".($#arr + 1));
43    
44     return @arr;
45     }
46    
47     sub estcmd {
48     my $q = shift;
49    
50     my $cmd = "estcmd search $index '$q'";
51     diag $cmd;
52    
53     open(my $fh, "$cmd |") || die "cmd: $!";
54     while(<$fh>) {
55     if (/^HIT=(\d+)/) {
56     return $1;
57     }
58     }
59     return undef;
60     }
61    
62     foreach my $q (qw(blade runner Philip filip dick)) {
63    
64     ok(my $hits = estcmd($q), "estcmd: $q");
65    
66     diag "$hits hits";
67    
68     cmp_ok(scalar pgest($q, '', 0, 0), '==', $hits, 'blade runner');
69     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26