#!/usr/bin/perl
-
+# =============================================================================
+# $Id: test.pl,v 1.7 2003-02-28 18:38:28 pop Exp $
+#
+# Perl API header
+# =============================================================================
BEGIN {
+ use Test::More tests => 15;
push (@INC,'demo','blib/lib','blib/arch');
+ use_ok('IDZebra::Session');
}
-
use pod;
-use Test::More tests => 15;
-
-BEGIN {
- use_ok('IDZebra::Session');
-}
IDZebra::logFile("test.log");
#IDZebra::logLevel(15);
-#IDZebra::init();
+IDZebra::init();
# ----------------------------------------------------------------------------
# Session opening and closing
groupName => 'demo1');
isa_ok($sess,"IDZebra::Session");
ok(defined($sess->{zh}), "Zebra handle opened");
+#use IDZebra::Repository;
# ----------------------------------------------------------------------------
# Record group tests
# ----------------------------------------------------------------------------
# repository upadte
+
+our $filecount = 5;
+
$sess->begin_trans;
$sess->update(path => 'lib');
my $stat = $sess->end_trans;
-ok(($stat->{inserted} == 6), "Inserted 6 records");
+ok(($stat->{inserted} == $filecount),
+ "Inserted $stat->{inserted}/$filecount records");
$sess->begin_trans;
$sess->update(groupName => 'demo1',
path => 'lib');
my $stat = $sess->end_trans;
-ok(($stat->{updated} == 6), "Updated 6 records");
+ok(($stat->{inserted} == $filecount),
+ "Inserted $stat->{inserted}/$filecount records");
$sess->begin_trans;
$sess->delete(groupName => 'demo1',
path => 'lib');
my $stat = $sess->end_trans;
-ok(($stat->{deleted} == 6), "Deleted 6 records");
+ok(($stat->{deleted} == $filecount),
+ "Deleted $stat->{deleted}/$filecount records");
$sess->begin_trans;
$sess->update(groupName => 'demo1',
path => 'lib');
my $stat = $sess->end_trans;
-ok(($stat->{inserted} == 6), "Inserted 6 records");
+ok(($stat->{inserted} == $filecount),
+ "Inserted $stat->{inserted}/$filecount records");
ok(($sess->group->{databaseName} eq "demo2"),"Original group is selected");
my $rec2=`cat lib/IDZebra/Filter.pm`;
$sess->begin_trans;
-my $s1=$sess->update_record(data => $rec1,
+my $s1=$sess->update_record(data => $rec2,
recordType => 'grs.perl.pod',
groupName => "demo1",
);
+my $stat = $sess->end_trans;
+ok(($stat->{updated} == 1), "Updated 1 records");
+
+# ----------------------------------------------------------------------------
+# search
+$sess->databases('demo2');
+#$sess->begin_read;
+my $rs1 = $sess->search(cqlmap => 'demo/cql.map',
+ cql => 'IDZebra',
+ databases => [qw(demo1 demo2)]);
+
+print STDERR "$rs1->{recordCount} hits.\n";
#my $s2=$sess->update_record(data => $rec2);
# recordType => "grs.perl.pod");
-my $stat = $sess->end_trans;
-ok(($stat->{updated} == 1), "Updated 1 records");
-
#$sess->cqlmap("cql.map");
#print STDERR $sess->cql2pqf("job.id <= 5");
#print STDERR $sess->cql2pqf("job.id=5 and dc.title=computer");