Quick test includes Record::OPAC rather than Record::Fetch
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / Bib1.pm
1
2 # See the "Main" test package for documentation
3
4 package ZOOM::IRSpy::Test::Search::Bib1;
5
6 use 5.008;
7 use strict;
8 use warnings;
9
10 use ZOOM::IRSpy::Test;
11 our @ISA = qw(ZOOM::IRSpy::Test);
12
13
14 sub start {
15     my $class = shift();
16     my($conn) = @_;
17     my @attrs = ( 1..63, 1000..1036,            # Bib-1
18                   1037..1096, 1185..1209,       # Extended Bib-1
19                   1097..1111,                   # Dublin-Core
20                   1112..1184                    # GILS
21                 );
22
23     foreach my $attr (@attrs) {
24         $conn->irspy_search_pqf("\@attr 1=$attr mineral",
25                                 {'attr' => $attr}, {},
26                                 ZOOM::Event::ZEND, \&found,
27                                 exception => \&error);
28     }
29 }
30
31
32 sub found {
33     my($conn, $task, $test_args, $event) = @_;
34     my $attr = $test_args->{'attr'};
35
36     my $n = $task->{rs}->size();
37     $task->{rs}->destroy();
38     $conn->log("irspy_test", "search on access-point $attr found $n record",
39                $n==1 ? "" : "s");
40     update($conn, $attr, 1);
41
42     return ZOOM::IRSpy::Status::TASK_DONE;
43 }
44
45
46 sub error {
47     my($conn, $task, $test_args, $exception) = @_;
48     my $attr = $test_args->{'attr'};
49
50     $task->{rs}->destroy();
51     $conn->log("irspy_test", "search on access-point $attr had error: ",
52                $exception);
53     update($conn, $attr, 0);
54     zoom_error_timeout_update($conn, $exception);
55
56     return ZOOM::IRSpy::Status::TEST_BAD
57         if ($exception->code() == 1 || # permanent system error
58             $exception->code() == 235 || # Database does not exist
59             $exception->code() == 109); # Database unavailable
60
61     return ZOOM::IRSpy::Status::TASK_DONE;
62 }
63
64
65 sub update {
66     my ($conn, $attr, $ok) = @_;
67     $conn->record()->store_result('search', 'set'       => 'bib-1',
68                                             'ap'        => $attr,
69                                             'ok'        => $ok);
70 }
71
72 1;