Update Perl internals so that it matches the current Zebra API.
[idzebra-moved-to-github.git] / perl / t / 02_directory_update.t
1 #!perl
2 # =============================================================================
3 # $Id: 02_directory_update.t,v 1.4 2004-07-28 08:15:47 adam Exp $
4 #
5 # Perl API header
6 # =============================================================================
7 BEGIN {
8     if ($ENV{PERL_CORE}) {
9         chdir 't' if -d 't';
10     }
11     push (@INC,'demo','blib/lib','blib/arch');
12 }
13
14 use strict;
15 use warnings;
16
17 use Test::More tests => 8;
18
19 # ----------------------------------------------------------------------------
20 # Session opening and closing
21 BEGIN {
22     use_ok('IDZebra');
23     unlink("test02.log");
24     IDZebra::logFile("test02.log");
25     use_ok('IDZebra::Session'); 
26     use_ok('pod');
27 }
28
29
30 # ----------------------------------------------------------------------------
31 # Session opening and closing
32 my $sess = IDZebra::Session->open(configFile => 'demo/zebra.cfg',
33                                   groupName  => 'demo2');
34 isa_ok($sess,"IDZebra::Session");
35
36 SKIP: {
37     skip "Takes a while", 5 if (0);
38
39 # ----------------------------------------------------------------------------
40 # init repository
41 $sess->init();
42 # ----------------------------------------------------------------------------
43 # repository upadte
44
45 # ADAM: we must set database separately (can't be used from group)
46 $sess->databases('demo2');
47
48 our $filecount = 8;
49 $sess->begin_trans;
50 $sess->update(path      =>  'lib');
51 my $stat = $sess->end_trans;
52
53 ok(($stat->{inserted} == $filecount), 
54    "Inserted $stat->{inserted}/$filecount records");
55
56 # ADAM: we must set database separately (can't be used from group)
57 $sess->databases('demo1');
58
59 $sess->begin_trans;
60 $sess->update(groupName => 'demo1',
61               path      =>  'lib');
62
63 $stat = $sess->end_trans;
64 ok(($stat->{inserted} == $filecount), 
65    "Inserted $stat->{inserted}/$filecount records");
66
67 $sess->begin_trans;
68 $sess->delete(groupName => 'demo1',
69               path      =>  'lib');
70 $stat = $sess->end_trans;
71 ok(($stat->{deleted} == $filecount), 
72    "Deleted $stat->{deleted}/$filecount records");
73
74 $sess->begin_trans;
75 $sess->update(groupName => 'demo1',
76               path      =>  'lib');
77
78 $stat = $sess->end_trans;
79 ok(($stat->{inserted} == $filecount), 
80    "Inserted $stat->{inserted}/$filecount records with shadow");
81
82 # ok(($sess->group->{databaseName} eq "demo2"),"Original group is selected"); deleted
83
84 # ----------------------------------------------------------------------------
85 # Close session
86 }
87 $sess->close;