]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/support-scripts/Cstore_test2.t
Add unit tests for LP 800269 - holdings for captions only
[working/Evergreen.git] / Open-ILS / src / support-scripts / Cstore_test2.t
1 #!/usr/bin/perl
2 # ---------------------------------------------------------------
3 # Copyright (C) 2010 Equinox Software, Inc
4 # Author: Joe Atzberger <jatzberger@esilibrary.com>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 # ---------------------------------------------------------------
16
17 use strict; use warnings;
18 use vars qw/ $session $e $i $call/;
19
20 use Test::More qw/no_plan/;
21
22 sub nappy {
23     if (@ARGV) {
24         my $nap = shift @ARGV;
25         diag("OK, this time we'll sleep for $nap seconds to see if CStore wakes up");
26         sleep $nap;
27     }
28 }
29
30 BEGIN {
31     $i = 5;
32     $call = 'retrieve_all_acq_edi_account';
33     use_ok('OpenILS::Utils::Cronscript');
34     ok($session = OpenILS::Utils::Cronscript->new()->session('open-ils.acq'),
35         "new session created");
36 }
37
38 INIT {
39     nappy();
40     use_ok('OpenILS::Utils::CStoreEditor');
41 }
42
43 nappy();
44
45 ok($e = OpenILS::Utils::CStoreEditor->new(xact => 1),
46     "new CStoreEditor created");
47
48 until (can_ok($e, $call) or $i-- == 0) {
49     diag("CStore FAIL: cannot $call");
50     sleep 2;
51     diag("reloading: prepare for a ton of warnings");
52     delete $INC{'OpenILS/Utils/CStoreEditor.pm'};
53     require_ok('OpenILS::Utils::CStoreEditor');
54     diag("reloaded");
55     ok($e = OpenILS::Utils::CStoreEditor->new(xact => 1),
56         "replacement CStoreEditor created");
57 }
58
59 my $set = $e->retrieve_all_acq_edi_account();
60 ok(defined($set), $call);
61 print "\ndone\n";
62