/[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

Diff of /trunk/t/pgest.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 49 by dpavlin, Sat Oct 29 18:54:40 2005 UTC revision 51 by dpavlin, Tue May 9 22:55:42 2006 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  use Test::More tests => 94;  use Test::More tests => 53;
6    
7  BEGIN {  BEGIN {
8          use_ok('DBI');          use_ok('DBI');
# Line 24  if ($pwd !~ m#^/#) { Line 24  if ($pwd !~ m#^/#) {
24  }  }
25  ok($pwd, "pwd: $pwd");  ok($pwd, "pwd: $pwd");
26  my $index = "$pwd/../data/casket/";  my $index = "$pwd/../data/casket/";
27    my $node = 'http://localhost:1978/node/trivia';
28    
29  my $sql = "select id from pgest('$index',?,?,?,?,?,array['\@id']) as (id text)";  my $sql = "select id from pgest('$node','admin','admin',0,?,?,?,?,?,array['\@id']) as (id text)";
30  diag "$sql";  diag $sql;
   
31  my $sth = $dbh->prepare($sql) || die $dbh->errstr();  my $sth = $dbh->prepare($sql) || die $dbh->errstr();
32  ok($sth, "sth");  ok($sth, "sth");
33    
 my $sql_node = "select id from pgest('http://localhost:1978/node/trivia','admin','admin',0,?,?,?,?,?,array['\@id']) as (id text)";  
 my $sth_node = $dbh->prepare($sql_node) || die $dbh->errstr();  
 ok($sth_node, "sth_node");  
   
34  sub pgest {  sub pgest {
35          $sth->execute(@_) || die "FATAL ERROR: direct " . $sth->errstr();          $sth->execute(@_) || die "FATAL ERROR: direct " . $sth->errstr();
         $sth_node->execute(@_) || die "FATAL ERROR: node ". $sth_node->errstr();  
36          {          {
37                  no warnings;                  no warnings;
38                  ok($sth, "execute(".join(",",@_).")");                  ok($sth, "execute(".join(",",@_).")");
                 ok($sth_node, "execute on node");  
39          }          }
40    
41          my @arr;          my @arr;
42          while (my ($id) = $sth->fetchrow_array() ) {          while (my ($id) = $sth->fetchrow_array() ) {
43                  push @arr, $id;                  push @arr, $id;
44          }          }
         my @arr_node;  
         while (my ($id) = $sth_node->fetchrow_array() ) {  
                 push @arr_node, $id;  
         }  
         cmp_ok($#arr, '==', $#arr_node, "pgest direct and node results");  
45    
46          return @arr;          return @arr;
47  }  }
48    
49  sub estcmd {  sub estcmd {
50          my $q = shift;          my ($q,$attr, $order, $limit, $offset) = @_;
         my $attr = shift;  
51    
52          my $cmd = "estcmd search ";          my $cmd = "estcall search -vu -sf";
53          $cmd .= " -attr '$attr' " if ($attr);          $cmd .= " -attr '$attr'" if ($attr);
54          $cmd .= " -max 999999 ";                # why do I need this?          $cmd .= " -ord '$order'" if ($order);
55            if ($limit) {
56                    $cmd .= " -max $limit";
57            } else {
58                    $cmd .= " -max 999999";
59            }
60            $cmd .= " -sk $offset" if ($offset);
61          $q ||= '';          $q ||= '';
62          $cmd .= "$index '$q'";          $cmd .= " $node '$q'";
63          diag $cmd;          diag $cmd;
64    
65          open(my $fh, "$cmd |") || die "cmd: $!";          open(my $fh, "$cmd |") || die "cmd: $!";
# Line 91  foreach my $q (qw(blade runner Philip k. Line 85  foreach my $q (qw(blade runner Philip k.
85    
86          diag "$hits hits";          diag "$hits hits";
87    
88          cmp_ok(scalar pgest($q, '', undef, 0, 0), '==', $hits, 'blade runner');          cmp_ok(scalar pgest($q, '', undef, 0, 0), '==', $hits, "pgest: $q");
89  }  }
90    
91  # test attr query  # test attr query
# Line 101  foreach my $q (('@title STRINC Blade Run Line 95  foreach my $q (('@title STRINC Blade Run
95    
96          diag "$hits hits";          diag "$hits hits";
97    
98          cmp_ok(scalar pgest(undef, $q, undef, 0, 0), '==', $hits, 'blade runner');          cmp_ok($hits, '==', scalar pgest(undef, $q, undef, 0, 0), 'blade runner');
99  }  }
100    
101  diag "Error handling test follows, ignore messages...";  diag "Error handling test follows, ignore messages...";

Legend:
Removed from v.49  
changed lines
  Added in v.51

  ViewVC Help
Powered by ViewVC 1.1.26