--- trunk/t/5_Node.t 2006/05/16 11:39:53 151 +++ trunk/t/5_Node.t 2006/05/16 12:11:39 152 @@ -3,22 +3,28 @@ use strict; use blib; -use Test::More tests => 270; +my $tests = 269; + +use Test::More; use Test::Exception; use Data::Dumper; BEGIN { use_ok('Search::Estraier') }; +plan tests => $tests; + my $debug = shift @ARGV; # name of node for test my $test1_node = '_test1_' . $$; my $test2_node = '_test2_' . $$; +my $estmaster_uri = $ENV{'ESTMASTER_URI'} || 'http://localhost:1978'; + ok(my $node = new Search::Estraier::Node( debug => $debug ), 'new'); isa_ok($node, 'Search::Estraier::Node'); -ok($node->set_url("http://localhost:1978/node/$test1_node"), "set_url $test1_node"); +ok($node->set_url("$estmaster_uri/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'; @@ -32,6 +38,11 @@ # test master functionality +SKIP: { + +skip "can't find estmaster at $estmaster_uri", ($tests - 9) if (! eval { $node->master( action => 'nodelist' ) } ); + +diag "using $estmaster_uri"; diag("node->master shutdown not tested"); diag("node->master backup not tested"); @@ -212,7 +223,7 @@ } ok(my $hints = $nres->hints, 'hints'); -diag Dumper($hints); +diag Dumper($hints) if ($debug); ok($node->_set_info, "refresh _set_info"); @@ -248,16 +259,16 @@ # user doesn't exist ok(! $node->set_user('foobar', 1), 'set_user'); -ok(my $node2 = new Search::Estraier::Node( "http://localhost:1978/node/$test2_node" ), "new $test2_node"); +ok(my $node2 = new Search::Estraier::Node( "$estmaster_uri/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"); +ok($node = new Search::Estraier::Node( url => "$estmaster_uri/non-existant", croak_on_error => 1 ), "new non-existant"); throws_ok { $node->name } qr/404/, 'croak on error'; # croak_on_error -ok($node = new Search::Estraier::Node( url => "http://localhost:1978/node/$test1_node", croak_on_error => 1 ), "new $test1_node"); +ok($node = new Search::Estraier::Node( url => "$estmaster_uri/node/$test1_node", croak_on_error => 1 ), "new $test1_node"); ok(! $node->uri_to_id('foobar'), 'uri_to_id without croak'); @@ -275,12 +286,12 @@ # now, test links my $test2_label = "$test2_node label"; -my $link_url = "http://localhost:1978/node/$test2_node"; +my $link_url = "$estmaster_uri/node/$test2_node"; ok($node->set_link( $link_url, $test2_label, 42), "set_link $test2_node ($test2_label) 42"); ok(my $links = $node->links, 'links'); cmp_ok($#{$links}, '==', 0, 'one link'); like($links->[0], qr/^$link_url/, 'link correct'); -ok($node->set_link("http://localhost:1978/node/$test2_node", $test2_label, 0), "set_link $test2_node ($test2_label) delete"); +ok($node->set_link("$estmaster_uri/node/$test2_node", $test2_label, 0), "set_link $test2_node ($test2_label) delete"); ok($msg = $node->master( action => 'nodeclr', @@ -302,7 +313,7 @@ my $node_label = "test $$ label"; ok($node = new Search::Estraier::Node( - url => "http://localhost:1978/node/$node_name", + url => "$estmaster_uri/node/$node_name", create => 1, label => $node_label, croak_on_error => 1 @@ -312,14 +323,14 @@ cmp_ok($node->label, 'eq', $node_label, "node label: $node_label"); ok($node = new Search::Estraier::Node( - url => "http://localhost:1978/node/$node_name", + url => "$estmaster_uri/node/$node_name", create => 1, label => $node_label, croak_on_error => 0 ), "new create existing"); ok($node = new Search::Estraier::Node( - url => "http://localhost:1978/node/$node_name", + url => "$estmaster_uri/node/$node_name", create => 1, label => $node_label, croak_on_error => 1 @@ -333,7 +344,7 @@ # and again, this time without node ok($node = new Search::Estraier::Node( - url => "http://localhost:1978/node/$node_name", + url => "$estmaster_uri/node/$node_name", create => 1, label => $node_label, croak_on_error => 0 @@ -350,4 +361,6 @@ ok($msg = $node->master( action => 'sync' ), "sync: $msg"); +} # SKIP + diag "over";