1 # $Id: Named.pm,v 1.3 2007-03-05 12:53:57 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();
34 ## How should we handle the situation when there is 0 hits?
36 my $rsrec = $rs->record(0);
37 if (!defined $rsrec) {
38 # I thought this was a "can't happen", but it sometimes
39 # does, as for example documented for
40 # kat.vkol.cz:9909/svk02 at ../../../../../tmp/bad-run-1
41 eval { $conn->check() };
42 return error($conn, $task, $test_args, $@);
44 $record = $rsrec->raw();
47 $conn->irspy_search_pqf("\@attr 1=4 4ds9da94",
48 {'record_a' => $record, 'hits_a' => $hits,
51 ZOOM::Event::ZEND, \&completed_search_b,
52 exception => \&error);
54 return ZOOM::IRSpy::Status::TASK_DONE;
58 sub completed_search_b {
59 my($conn, $task, $test_args, $event) = @_;
60 my $rs = $test_args->{rs_a};
66 if ($test_args->{'hits_a'} > 0) {
67 my $hits = $rs->size();
68 my $record = $rs->record(0)->raw();
70 if ($hits != $test_args->{'hits_a'}) {
71 $conn->log('irspy_test', 'Named result set not supported: ',
72 'Mis-matching hit counts');
76 if ($record ne $test_args->{'record_a'}) {
77 $conn->log('irspy_test', 'Named result set not supported: ',
78 'Mis-matching records');
83 update($conn, $error eq '' ? 1 : 0, $error);
85 return ZOOM::IRSpy::Status::TASK_DONE;
90 my($conn, $task, $test_args, $exception) = @_;
92 $conn->log("irspy_test", "Named resultset check failed:", $exception);
93 return ZOOM::IRSpy::Status::TASK_DONE;
98 my ($conn, $ok, $error) = @_;
99 my %args = ('ok' => $ok);
102 $args{'error'} = $error;
105 $conn->record()->store_result('named_resultset', %args);