2 # See the "Main" test package for documentation
4 package ZOOM::IRSpy::Test::ResultSet::Named;
10 use ZOOM::IRSpy::Test;
11 our @ISA = qw(ZOOM::IRSpy::Test);
18 $conn->log('irspy_test', 'Testing for named resultset support');
20 $conn->irspy_search_pqf("\@attr 1=4 mineral", {},
21 {'setname' => 'a', 'start' => 0, 'count' => 0},
22 ZOOM::Event::ZEND, \&completed_search_a,
23 exception => \&error);
27 sub completed_search_a {
28 my ($conn, $task, $test_args, $event) = @_;
31 my $hits = $rs->size();
34 ### We should try other searches as in Record::Fetch
36 return ZOOM::IRSpy::Status::TEST_BAD;
38 my $rsrec = $rs->record(0);
39 if (!defined $rsrec) {
40 # I thought this was a "can't happen", but it sometimes
41 # does, as for example documented for
42 # kat.vkol.cz:9909/svk02 at ../../../../../tmp/bad-run-1
44 eval { $conn->check() };
45 return error($conn, $task, $test_args, $@);
47 $record = $rsrec->raw();
50 $conn->irspy_search_pqf("\@attr 1=4 4ds9da94",
51 {'record_a' => $record, 'hits_a' => $hits,
54 ZOOM::Event::ZEND, \&completed_search_b,
55 exception => \&error);
57 return ZOOM::IRSpy::Status::TASK_DONE;
61 sub completed_search_b {
62 my($conn, $task, $test_args, $event) = @_;
63 my $rs = $test_args->{rs_a};
67 $task->{rs}->destroy(); # We only care about the original search
70 if ($test_args->{'hits_a'} == 0) {
71 die "can't happen: hits_a == 0";
73 my $hits = $rs->size();
74 my $rsrec = $rs->record(0);
75 if (!defined $rsrec) {
77 eval { $conn->check() };
78 return error($conn, $task, $test_args, $@);
80 my $record = $rsrec->raw();
82 if ($hits != $test_args->{'hits_a'}) {
83 $conn->log('irspy_test', 'Named result set not supported: ',
84 'Mis-matching hit counts');
88 if (!defined $record || $record ne $test_args->{'record_a'}) {
89 $conn->log('irspy_test', 'Named result set not supported: ',
90 'Mis-matching records');
95 update($conn, $error eq '' ? 1 : 0, $error);
98 return ZOOM::IRSpy::Status::TASK_DONE;
103 my($conn, $task, $test_args, $exception) = @_;
105 $conn->log("irspy_test", "Named resultset check failed:", $exception);
106 zoom_error_timeout_update($conn, $exception);
107 return ZOOM::IRSpy::Status::TASK_DONE;
112 my ($conn, $ok, $error) = @_;
113 my %args = ('ok' => $ok);
116 $args{'error'} = $error;
119 $conn->record()->store_result('named_resultset', %args);