Adding Bib-1 test case.
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / Bib1.pm
1 # $Id: Bib1.pm,v 1.1 2006-09-26 13:12:28 sondberg Exp $
2
3 # See the "Main" test package for documentation
4
5 package ZOOM::IRSpy::Test::Search::Bib1;
6
7 use 5.008;
8 use strict;
9 use warnings;
10 use Data::Dumper;
11
12 use ZOOM::IRSpy::Test;
13 our @ISA = @ISA = qw(ZOOM::IRSpy::Test);
14 our @Bib1_Attr = qw(1 2 3 4 5 6 7 8 9); 
15
16
17 sub run {
18     my $this = shift();
19     my $irspy = $this->irspy();
20     my $pod = $irspy->pod();
21
22     $pod->callback(ZOOM::Event::RECV_SEARCH, \&found);
23
24     foreach my $attr (@Bib1_Attr) {
25         $pod->search_pqf('@attr 1=' . $attr . ' water' );
26         my $err = $pod->wait({'irspy' => $irspy, 'attr' => $attr});
27     }
28
29     return 0;
30 }
31
32
33 sub found {
34     my($conn, $href, $rs, $event) = @_;
35     my $irspy = $href->{'irspy'};
36     my $attr = $href->{'attr'};
37     my $n = $rs->size();
38     my $rec = $irspy->record($conn);
39
40     $irspy->log("irspy_test", $conn->option("host"),
41                 " Bib-1 attribute=$attr search found $n record",
42                 $n==1 ? "" : "s");
43
44     $rec->append_entry("irspy:status", "<irspy:search set='bib1' attr='$attr'" .
45                        " ok='1'>" . $irspy->isodate(time()) .
46                        "</irspy:search>");
47     return 0;
48 }
49
50
51 1;