X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=lib%2FZOOM%2FIRSpy%2FTest%2FResultSet%2FNamed.pm;h=7da25961e590b026b1f3ca95cb3084854e24641f;hb=e61887a109576fa0e066547c0ce033631a290f8f;hp=3a5a950c5d4b6b2a67459e069b21a7e32f611109;hpb=eb28bd29ed17e00209d4a95f8ebe4046cdb8319d;p=irspy-moved-to-github.git diff --git a/lib/ZOOM/IRSpy/Test/ResultSet/Named.pm b/lib/ZOOM/IRSpy/Test/ResultSet/Named.pm index 3a5a950..7da2596 100644 --- a/lib/ZOOM/IRSpy/Test/ResultSet/Named.pm +++ b/lib/ZOOM/IRSpy/Test/ResultSet/Named.pm @@ -1,4 +1,3 @@ -# $Id: Named.pm,v 1.1 2006-11-02 11:46:40 sondberg Exp $ # See the "Main" test package for documentation @@ -19,8 +18,8 @@ sub start { $conn->log('irspy_test', 'Testing for named resultset support'); $conn->irspy_search_pqf("\@attr 1=4 mineral", {}, - {'setname' => 'a', 'start' => 0, 'count' => 0}, - ZOOM::Event::RECV_SEARCH, \&completed_search_a, + {'setname' => 'a', 'start' => 0, 'count' => 0}, + ZOOM::Event::ZEND, \&completed_search_a, exception => \&error); } @@ -31,16 +30,28 @@ sub completed_search_a { my $record = ''; my $hits = $rs->size(); - ## How should be handle the situation when there is 0 hits? - if ($hits > 0) { - $record = $rs->record(0)->raw(); + if ($hits == 0) { + ### We should try other searches as in Record::Fetch + $rs->destroy(); + return ZOOM::IRSpy::Status::TEST_BAD; + } else { + my $rsrec = $rs->record(0); + if (!defined $rsrec) { + # I thought this was a "can't happen", but it sometimes + # does, as for example documented for + # kat.vkol.cz:9909/svk02 at ../../../../../tmp/bad-run-1 + $rs->destroy(); + eval { $conn->check() }; + return error($conn, $task, $test_args, $@); + } + $record = $rsrec->raw(); } $conn->irspy_search_pqf("\@attr 1=4 4ds9da94", {'record_a' => $record, 'hits_a' => $hits, 'rs_a' => $rs}, {'setname' => 'b'}, - ZOOM::Event::RECV_SEARCH, \&completed_search_b, + ZOOM::Event::ZEND, \&completed_search_b, exception => \&error); return ZOOM::IRSpy::Status::TASK_DONE; @@ -53,11 +64,20 @@ sub completed_search_b { my $record = ''; my $error = ''; + $task->{rs}->destroy(); # We only care about the original search $rs->cache_reset(); - if ($test_args->{'hits_a'} > 0) { + if ($test_args->{'hits_a'} == 0) { + die "can't happen: hits_a == 0"; + } else { my $hits = $rs->size(); - my $record = $rs->record(0)->raw(); + my $rsrec = $rs->record(0); + if (!defined $rsrec) { + $rs->destroy(); + eval { $conn->check() }; + return error($conn, $task, $test_args, $@); + } + my $record = $rsrec->raw(); if ($hits != $test_args->{'hits_a'}) { $conn->log('irspy_test', 'Named result set not supported: ', @@ -65,7 +85,7 @@ sub completed_search_b { $error = 'hitcount'; } - if ($record ne $test_args->{'record_a'}) { + if (!defined $record || $record ne $test_args->{'record_a'}) { $conn->log('irspy_test', 'Named result set not supported: ', 'Mis-matching records'); $error = 'record'; @@ -74,6 +94,7 @@ sub completed_search_b { update($conn, $error eq '' ? 1 : 0, $error); + $rs->destroy(); return ZOOM::IRSpy::Status::TASK_DONE; }