--- trunk/t/5_Node.t 2006/01/09 15:22:43 72 +++ trunk/t/5_Node.t 2006/01/16 21:47:21 79 @@ -3,7 +3,7 @@ use strict; use blib; -use Test::More tests => 95; +use Test::More tests => 97; use Test::Exception; use Data::Dumper; @@ -12,13 +12,13 @@ my $debug = 0; # name of node for test -my $test_node = 'test1'; -my $test1_node = 'test2'; +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/$test_node"), "set_url $test_node"); +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'; @@ -30,6 +30,10 @@ cmp_ok($node->status, '==', -1, 'status'); +SKIP: { + +skip "no $test1_node node in Hyper Estraier", 87, unless($node->name); + my @res = ( -1, 200 ); my $nodelist; @@ -52,10 +56,6 @@ #diag "draft:\n$draft"; ok(my $doc = new Search::Estraier::Document($draft), 'new doc from draft'); -SKIP: { - -skip "no $test_node node in Hyper Estraier", 81, unless($node->name); - ok( $node->put_doc($doc), "put_doc data001"); for ( 1 .. 10 ) { @@ -123,16 +123,21 @@ # user doesn't exist ok(! $node->set_user('foobar', 1), 'set_user'); -ok(my $node1 = new Search::Estraier::Node( "http://localhost:1978/node/$test1_node" ), "new $test1_node"); -ok($node1->set_auth('admin','admin'), "set_auth $test1_node"); +ok(my $node1 = new Search::Estraier::Node( "http://localhost:1978/node/$test2_node" ), "new $test2_node"); +ok($node1->set_auth('admin','admin'), "set_auth $test2_node"); + +# croak_on_error + +ok(my $node2 = new Search::Estraier::Node( url => "http://localhost:1978/non-existant", croak_on_error => 1 ), "new non-existant"); +throws_ok { $node2->name } qr/404/, 'croak on error'; SKIP: { - skip "no $test1_node in Hyper Estraier, skipping set_link", 2 unless (my $test1_label = $node1->label); + skip "no $test2_node in Hyper Estraier, skipping set_link", 2 unless (my $test1_label = $node1->label); - ok($node->set_link("http://localhost:1978/node/$test1_node", $test1_label, 42), "set_link $test1_node ($test1_label) 42"); - ok($node->set_link("http://localhost:1978/node/$test1_node", $test1_label, 0), "set_link $test1_node ($test1_label) delete"); -} + ok($node->set_link("http://localhost:1978/node/$test2_node", $test1_label, 42), "set_link $test2_node ($test1_label) 42"); + ok($node->set_link("http://localhost:1978/node/$test2_node", $test1_label, 0), "set_link $test2_node ($test1_label) delete"); +} # SKIP 2 -} +} # SKIP 1 diag "over";