Zebra perl API following changes in zebraapi.c/.h (all functions returning
[idzebra-moved-to-github.git] / perl / t / 03_record_update.t
index ab15e07..762c78a 100644 (file)
@@ -1,6 +1,6 @@
 #!perl
 # =============================================================================
-# $Id: 03_record_update.t,v 1.3 2003-03-13 04:25:18 pop Exp $
+# $Id: 03_record_update.t,v 1.6 2003-07-07 10:59:33 pop Exp $
 #
 # Perl API header
 # =============================================================================
@@ -8,13 +8,13 @@ BEGIN {
     if ($ENV{PERL_CORE}) {
         chdir 't' if -d 't';
     }
-    push (@INC,'demo','blib/lib','blib/arch');
+    unshift (@INC,'demo','blib/lib','blib/arch');
 }
 
 use strict;
 use warnings;
 
-use Test::More tests => 11;
+use Test::More tests => 18;
 
 # ----------------------------------------------------------------------------
 # Session opening and closing
@@ -37,6 +37,7 @@ isa_ok($sess,"IDZebra::Session");
 # per record update
 my $rec1=`cat lib/IDZebra/Data1.pm`;
 my $rec2=`cat lib/IDZebra/Filter.pm`;
+my $rec3=`cat lib/IDZebra/Session.pm`;
 
 my ($sysno, $stat);
 
@@ -76,6 +77,64 @@ ok(($stat->{updated} == 0), "Updated 0 records");
 ok(($sysno < 0),"Inserted record got invalid sysno");
 
 
+$sess->begin_trans;
+my $sysno1 = $sess->update_record(data       => $rec2,
+                                 recordType => 'grs.perl.pod',
+                                 groupName  => "demo1",
+                                 );
+
+my $sysno2 = $sess->update_record(data       => $rec2,
+                                 recordType => 'grs.perl.pod',
+                                 groupName  => "demo1",
+                                 );
+
+$stat = $sess->end_trans;
+ok(($stat->{inserted} == 0), "Inserted 0 records");
+ok(($stat->{updated} == 1), "Updated $stat->{updated} records");
+ok(($sysno1 > 0),"Updated record got valid sysno");
+ok(($sysno2 < 0),"Unupdated record got invalid sysno");
+
+$sess->begin_trans;
+$sysno = $sess->delete_record(data       => $rec3,
+                             recordType => 'grs.perl.pod',
+                             groupName  => "demo1",
+                             );
+$stat = $sess->end_trans;
+
+
+$sess->begin_trans;
+$sysno = $sess->update_record(data       => $rec2,
+                             recordType => 'grs.perl.pod',
+                             groupName  => "demo1",
+                             );
+
+foreach my $i (1..100) {
+    $sysno = $sess->update_record(data       => $rec2,
+                                 recordType => 'grs.perl.pod',
+                                 groupName  => "demo1",
+                                 force      => 1,
+                                 );
+}
+foreach my $i (1..10) {
+    $sysno = $sess->update_record(data       => $rec3,
+                                 recordType => 'grs.perl.pod',
+                                 groupName  => "demo1",
+                                 force      => 1,
+                                 );
+}
+foreach my $i (1..10) {
+    $sysno = $sess->update_record(data       => $rec2,
+                                 recordType => 'grs.perl.pod',
+                                 groupName  => "demo1",
+                                 force      => 1,
+                                 );
+}
+
+
+$stat = $sess->end_trans;
+ok(($stat->{inserted} == 1), "Inserted $stat->{inserted} records");
+ok(($stat->{updated} == 120), "Updated $stat->{updated} records");
+ok(($sysno > 0),"Inserted got valid sysno");
 
 # ----------------------------------------------------------------------------
 # Close session