Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/irspy
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / DBDate.pm
1
2 # This plugin tests searching on BIB-1 access-point 1011 (Date/time
3 # added to db), the significance of which is that this search
4 # "succeeds" on some of our test databases
5 # (e.g. bagel.indexdata.com:210/marc) and fails on others
6 # (e.g. z3950.loc.gov:7090/Voyager gives error 114 "Unsupported Use
7 # attribute").  This allows us to test IRSpy's differing behaviour
8 # when a test succeeds or fails.
9
10 package ZOOM::IRSpy::Test::Search::DBDate;
11
12 use 5.008;
13 use strict;
14 use warnings;
15
16 use ZOOM::IRSpy::Test;
17 our @ISA = qw(ZOOM::IRSpy::Test);
18
19 use ZOOM::IRSpy::Utils qw(isodate);
20
21
22 sub start {
23     my $class = shift();
24     my($conn) = @_;
25
26     $conn->irspy_search_pqf('@attr 1=1011 mineral', undef, {},
27                             ZOOM::Event::ZEND, \&found,
28                             "exception", \&error);
29 }
30
31
32 sub found {
33     my($conn, $task, $__UNUSED_udata, $event) = @_;
34
35     my $n = $task->{rs}->size();
36     $conn->log("irspy_test",
37                "DB-date search found $n record", $n==1 ? "" : "s");
38     my $rec = $conn->record();
39     $rec->append_entry("irspy:status", "<irspy:search_dbdate ok='1'>" .
40                        isodate(time()) . "</irspy:search_dbdate>");
41
42     return ZOOM::IRSpy::Status::TASK_DONE;
43 }
44
45
46 sub error {
47     my($conn, $task, $__UNUSED_udata, $exception) = @_;
48
49     $conn->log("irspy_test", "DB-date search had error: $exception");
50     my $rec = $conn->record();
51     $rec->append_entry("irspy:status", "<irspy:search_dbdate ok='0'>" .
52                        isodate(time()) . "</irspy:search_dbdate>");
53     zoom_error_timeout_update($conn, $exception);
54     return ZOOM::IRSpy::Status::TEST_BAD;
55 }
56
57
58 1;