complete error timeout handling for all tests
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / Title.pm
1
2 # See the "Main" test package for documentation
3
4 package ZOOM::IRSpy::Test::Search::Title;
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 use ZOOM::IRSpy::Utils qw(isodate);
14
15
16 sub start {
17     my $class = shift();
18     my($conn) = @_;
19
20     $conn->irspy_search_pqf('@attr 1=4 mineral', undef, {},
21                             ZOOM::Event::ZEND, \&found,
22                             "exception", \&error);
23 }
24
25
26 sub found {
27     my($conn, $task, $__UNUSED_udata, $event) = @_;
28
29     my $n = $task->{rs}->size();
30     $conn->log("irspy_test",
31                "title search found $n record", $n==1 ? "" : "s");
32     my $rec = $conn->record();
33     $rec->append_entry("irspy:status", "<irspy:search_title ok='1'>" .
34                        isodate(time()) . "</irspy:search_title>");
35
36     return ZOOM::IRSpy::Status::TASK_DONE;
37 }
38
39
40 sub error {
41     my($conn, $task, $__UNUSED_udata, $exception) = @_;
42
43     $conn->log("irspy_test", "title search had error: $exception");
44     my $rec = $conn->record();
45     $rec->append_entry("irspy:status", "<irspy:search_title ok='0'>" .
46                        isodate(time()) . "</irspy:search_title>");
47     zoom_error_timeout_update($conn, $exception);
48     return ZOOM::IRSpy::Status::TEST_BAD;
49 }
50
51
52 1;