From: mike Date: Wed, 12 Oct 2005 14:31:53 +0000 (+0000) Subject: Now runs in parallel to 1-Net-Z3950-ZOOM.t: 11 tests, no output. X-Git-Tag: cpan_1_22~467 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=428d1d65fbccec06c6146b33cfe7f4b48c852df4;p=ZOOM-Perl-moved-to-github.git Now runs in parallel to 1-Net-Z3950-ZOOM.t: 11 tests, no output. --- diff --git a/t/2-ZOOM.t b/t/2-ZOOM.t index a8ce10c..98d4ded 100644 --- a/t/2-ZOOM.t +++ b/t/2-ZOOM.t @@ -1,4 +1,4 @@ -# $Id: 2-ZOOM.t,v 1.2 2005-10-12 11:56:27 mike Exp $ +# $Id: 2-ZOOM.t,v 1.3 2005-10-12 14:31:53 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl ZOOM.t' @@ -8,7 +8,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; use strict; -use Test::More tests => 1; +use Test::More tests => 11; BEGIN { use_ok('ZOOM') }; ######################### @@ -16,28 +16,44 @@ BEGIN { use_ok('ZOOM') }; # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. -my $host = "indexdata.com/gils"; -$host = "localhost:3950"; -my $port = 0; +my $host = "no.such.host"; +my $conn; +eval { $conn = new ZOOM::Connection($host, 0) }; +ok($@ && $@->isa("ZOOM::Exception") && + $@->code() == ZOOM::Error::CONNECT && $@->addinfo() eq $host, + "connection to non-existent host '$host' fails"); -my $conn = new ZOOM::Connection($host, $port); +$host = "indexdata.com/gils"; +eval { $conn = new ZOOM::Connection($host, 0) }; +ok(!$@, "connection to '$host' OK"); my $syntax = "usmarc"; $conn->option(preferredRecordSyntax => $syntax); my $val = $conn->option("preferredRecordSyntax"); -die "set preferredRecordSyntax to '$syntax' but got '$val'" - if $val ne $syntax; +ok($val eq $syntax, "preferred record syntax set to '$val'"); -my $query = '@attr 1=4 minerals'; -my $rs = $conn->search_pqf($query); +my $query = '@attr @and 1=4 minerals'; +my $rs; +eval { $rs = $conn->search_pqf($query) }; +ok($@ && $@->isa("ZOOM::Exception") && + $@->code() == ZOOM::Error::INVALID_QUERY, + "search for invalid query '$query' fails"); + +$query = '@attr 1=4 minerals'; +eval { $rs = $conn->search_pqf($query) }; +ok(!$@, "search for '$query' OK"); my $n = $rs->size($rs); +ok($n == 1, "found 1 record as expected"); -for (my $i = 0; $i < $n; $i++) { - my $rec = $rs->record($i); - my $data = $rec->render(); - my $raw = $rec->raw(); -} +my $rec = $rs->record(0); +my $data = $rec->render(); +ok($data =~ /245 +\$a ISOTOPIC DATES OF ROCKS AND MINERALS/, + "rendered record has expected title"); +my $raw = $rec->raw(); +ok($raw =~ /^00981n/, "raw record contains expected header"); $rs->destroy(); +ok(1, "destroyed result-set"); $conn->destroy(); +ok(1, "destroyed connection");