X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=t%2F26-packages.t;h=e60b5f37a0a1c1cae77ef46c08809b072ba033a4;hb=87c72eaf97a3dbf51a93dab782c2909539addc48;hp=4c3ff960fee62fbd1f482f664be02d5bd14176cb;hpb=19397f5285466f6fade800793e7b73e703bc6502;p=ZOOM-Perl-moved-to-github.git diff --git a/t/26-packages.t b/t/26-packages.t index 4c3ff96..e60b5f3 100644 --- a/t/26-packages.t +++ b/t/26-packages.t @@ -1,19 +1,15 @@ -# $Id: 26-packages.t,v 1.2 2005-12-09 10:33:48 mike Exp $ - # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 26-packages.t' use strict; use warnings; -use Test::More tests => 40; +use Test::More tests => 39; BEGIN { use_ok('ZOOM') }; -# For now, use a local database: later establish a public one for this. # We will create, and destroy, a new database with a random name -my $host = "localhost:9999"; -#my $host = "indexdata.com/gils"; +my $host = "z3950.indexdata.com:2100"; my $dbname = join("", map { chr(ord("a") + int(rand(26))) } 1..10); # Connect anonymously, and expect this to fail @@ -34,33 +30,32 @@ makedb($conn, $dbname, 223); $conn->destroy(); $conn = makeconn($host, "admin", "fish", 0); $conn->option(databaseName => $dbname); -count_hits($conn, "the", 109); +count_hits($conn, $dbname, "the", 109); # Now create the database and check that it is present but empty makedb($conn, $dbname, 0); -count_hits($conn, "the", 0, 0); +count_hits($conn, $dbname, "the", 114); # Trying to create the same database again will fail EEXIST makedb($conn, $dbname, 224); # Add a single record, and check that it can be found updaterec($conn, 1, content_of("samples/records/esdd0006.grs"), 0); -count_hits($conn, "the", 0, 1); +count_hits($conn, $dbname, "the", 0, 1); # Add the same record with the same ID: overwrite => no change updaterec($conn, 1, content_of("samples/records/esdd0006.grs"), 0); -count_hits($conn, "the", 0, 1); +count_hits($conn, $dbname, "the", 0, 1); # Add it again record with different ID => new copy added updaterec($conn, 2, content_of("samples/records/esdd0006.grs"), 0); -count_hits($conn, "the", 0, 2); +count_hits($conn, $dbname, "the", 0, 2); # Now drop the newly-created database dropdb($conn, $dbname, 0); -# A second dropping should fail, but does not do so -- I think that -# "drop" is an always-"successful" no-op. Yuck. -dropdb($conn, $dbname, 0); +# A second dropping should fail, as the database is no longer there. +dropdb($conn, $dbname, 235); sub makeconn { @@ -121,7 +116,7 @@ sub dropdb { my $p = $conn->package(); # No need to keep ok()ing this, or checking the option-setting $p->option(databaseName => $dbname); - $p->send("drop"); + eval { $p->send("drop") }; my($errcode, $errmsg, $addinfo) = maybe_error($@); ok($errcode == $expected_error, "database drop '$dbname'" . ($errcode ? " refused $errcode" : "")); @@ -154,7 +149,7 @@ sub updaterec { sub count_hits { - my($conn, $query, $expected_error, $expected_count) = @_; + my($conn, $dbname, $query, $expected_error, $expected_count) = @_; my $rs; eval { $rs = $conn->search_pqf($query) }; @@ -194,3 +189,13 @@ sub maybe_error { return (0, undef, undef); } } + + +# To investigate the set of databases created, use Explain Classic: +# +# $ yaz-client -u admin/fish test.indexdata.com:2118/IR-Explain-1 +# Z> find @attr exp1 1=1 databaseinfo +# Z> format xml +# Z> show 3 +# +# It seems that Explain still knows about dropped databases.