--- trunk/t/5_Node.t 2006/01/06 20:58:26 57 +++ trunk/t/5_Node.t 2006/01/28 17:38:00 94 @@ -3,7 +3,7 @@ use strict; use blib; -use Test::More tests => 92; +use Test::More tests => 98; use Test::Exception; use Data::Dumper; @@ -12,12 +12,13 @@ my $debug = 0; # name of node for test -my $test_node = 'Search-Estraier'; +my $test1_node = 'test1'; +my $test2_node = 'test2'; ok(my $node = new Search::Estraier::Node( debug => $debug ), 'new'); isa_ok($node, 'Search::Estraier::Node'); -ok($node->set_url('http://localhost:1978/node/searchestraier'), 'set_url'); +ok($node->set_url("http://localhost:1978/node/$test1_node"), "set_url $test1_node"); ok($node->set_proxy('', 8080), 'set_proxy'); throws_ok {$node->set_proxy('proxy.example.com', 'foo') } qr/port/, 'set_proxy port NaN'; @@ -29,6 +30,10 @@ cmp_ok($node->status, '==', -1, 'status'); +SKIP: { + +skip "no $test1_node node in Hyper Estraier", 88, unless($node->name); + my @res = ( -1, 200 ); my $nodelist; @@ -85,11 +90,11 @@ cmp_ok($node->cond_to_query( $cond ), 'eq' , 'phrase=girl&attr1=%40title%20STRINC%20Material&order=%40uri%20ASCD&max='.$max.'&wwidth=480&hwidth=96&awidth=96', 'cond_to_query'); -ok( my $nrec = $node->search( $cond, 0 ), 'search'); +ok( my $nres = $node->search( $cond, 0 ), 'search'); -isa_ok( $nrec, 'Search::Estraier::NodeResult' ); +isa_ok( $nres, 'Search::Estraier::NodeResult' ); -cmp_ok($nrec->doc_num, '==', $max, "doc_num = $max"); +cmp_ok($nres->doc_num, '==', $max, "doc_num = $max"); for ( 6 .. 10 ) { my $uri = 'test' . $_; @@ -104,6 +109,11 @@ ok( eq_hash( $k, $k2 ), "keywords"); } +ok(my $hints = $nres->hints, 'hints'); +diag Dumper($hints); + +ok($node->_set_info, "refresh _set_info"); + my $v; ok($v = $node->name, "name: $v"); ok($v = $node->label, "label: $v"); @@ -116,7 +126,24 @@ # user doesn't exist ok(! $node->set_user('foobar', 1), 'set_user'); -ok($node->set_link('test','test', 42), 'set_link test 42'); -ok($node->set_link('test','test', 0), 'set_link delete'); +ok(my $node2 = new Search::Estraier::Node( "http://localhost:1978/node/$test2_node" ), "new $test2_node"); +ok($node2->set_auth('admin','admin'), "set_auth $test2_node"); + +# croak_on_error + +ok($node = new Search::Estraier::Node( url => "http://localhost:1978/non-existant", croak_on_error => 1 ), "new non-existant"); +throws_ok { $node->name } qr/404/, 'croak on error'; + +# support for undef and 0 values +#ok($node = new Search::Estraier::Node( url => "http://localhost:1978/$test1_node", croak_on_error => 1 ), "new $test1_node"); + +SKIP: { + skip "no $test2_node in Hyper Estraier, skipping set_link", 2 unless (my $test2_label = $node2->label); + + ok($node->set_link("http://localhost:1978/node/$test2_node", $test2_label, 42), "set_link $test2_node ($test2_label) 42"); + ok($node->set_link("http://localhost:1978/node/$test2_node", $test2_label, 0), "set_link $test2_node ($test2_label) delete"); +} # SKIP 2 + +} # SKIP 1 diag "over";