1 # $Id: Named.pm,v 1.6 2007-08-01 15:11:20 mike Exp $
3 # See the "Main" test package for documentation
5 package ZOOM::IRSpy::Test::ResultSet::Named;
11 use ZOOM::IRSpy::Test;
12 our @ISA = qw(ZOOM::IRSpy::Test);
19 $conn->log('irspy_test', 'Testing for named resultset support');
21 $conn->irspy_search_pqf("\@attr 1=4 mineral", {},
22 {'setname' => 'a', 'start' => 0, 'count' => 0},
23 ZOOM::Event::ZEND, \&completed_search_a,
24 exception => \&error);
28 sub completed_search_a {
29 my ($conn, $task, $test_args, $event) = @_;
32 my $hits = $rs->size();
35 ### We should try other searches as in Record::Fetch
37 return ZOOM::IRSpy::Status::TEST_BAD;
39 my $rsrec = $rs->record(0);
40 if (!defined $rsrec) {
41 # I thought this was a "can't happen", but it sometimes
42 # does, as for example documented for
43 # kat.vkol.cz:9909/svk02 at ../../../../../tmp/bad-run-1
45 eval { $conn->check() };
46 return error($conn, $task, $test_args, $@);
48 $record = $rsrec->raw();
51 $conn->irspy_search_pqf("\@attr 1=4 4ds9da94",
52 {'record_a' => $record, 'hits_a' => $hits,
55 ZOOM::Event::ZEND, \&completed_search_b,
56 exception => \&error);
58 return ZOOM::IRSpy::Status::TASK_DONE;
62 sub completed_search_b {
63 my($conn, $task, $test_args, $event) = @_;
64 my $rs = $test_args->{rs_a};
68 $task->{rs}->destroy(); # We only care about the original search
71 if ($test_args->{'hits_a'} == 0) {
72 die "can't happen: hits_a == 0";
74 my $hits = $rs->size();
75 my $rsrec = $rs->record(0);
76 if (!defined $rsrec) {
78 eval { $conn->check() };
79 return error($conn, $task, $test_args, $@);
81 my $record = $rsrec->raw();
83 if ($hits != $test_args->{'hits_a'}) {
84 $conn->log('irspy_test', 'Named result set not supported: ',
85 'Mis-matching hit counts');
89 if (!defined $record || $record ne $test_args->{'record_a'}) {
90 $conn->log('irspy_test', 'Named result set not supported: ',
91 'Mis-matching records');
96 update($conn, $error eq '' ? 1 : 0, $error);
99 return ZOOM::IRSpy::Status::TASK_DONE;
104 my($conn, $task, $test_args, $exception) = @_;
106 $conn->log("irspy_test", "Named resultset check failed:", $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);