3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 95; |
use Test::More tests => 97; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
12 |
my $debug = 0; |
my $debug = 0; |
13 |
|
|
14 |
# name of node for test |
# name of node for test |
15 |
my $test_node = 'test1'; |
my $test1_node = 'test1'; |
16 |
my $test1_node = 'test2'; |
my $test2_node = 'test2'; |
17 |
|
|
18 |
ok(my $node = new Search::Estraier::Node( debug => $debug ), 'new'); |
ok(my $node = new Search::Estraier::Node( debug => $debug ), 'new'); |
19 |
isa_ok($node, 'Search::Estraier::Node'); |
isa_ok($node, 'Search::Estraier::Node'); |
20 |
|
|
21 |
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"); |
22 |
|
|
23 |
ok($node->set_proxy('', 8080), 'set_proxy'); |
ok($node->set_proxy('', 8080), 'set_proxy'); |
24 |
throws_ok {$node->set_proxy('proxy.example.com', 'foo') } qr/port/, 'set_proxy port NaN'; |
throws_ok {$node->set_proxy('proxy.example.com', 'foo') } qr/port/, 'set_proxy port NaN'; |
32 |
|
|
33 |
SKIP: { |
SKIP: { |
34 |
|
|
35 |
skip "no $test_node node in Hyper Estraier", 85, unless($node->name); |
skip "no $test1_node node in Hyper Estraier", 87, unless($node->name); |
36 |
|
|
37 |
my @res = ( -1, 200 ); |
my @res = ( -1, 200 ); |
38 |
|
|
123 |
# user doesn't exist |
# user doesn't exist |
124 |
ok(! $node->set_user('foobar', 1), 'set_user'); |
ok(! $node->set_user('foobar', 1), 'set_user'); |
125 |
|
|
126 |
ok(my $node1 = new Search::Estraier::Node( "http://localhost:1978/node/$test1_node" ), "new $test1_node"); |
ok(my $node1 = new Search::Estraier::Node( "http://localhost:1978/node/$test2_node" ), "new $test2_node"); |
127 |
ok($node1->set_auth('admin','admin'), "set_auth $test1_node"); |
ok($node1->set_auth('admin','admin'), "set_auth $test2_node"); |
128 |
|
|
129 |
|
# croak_on_error |
130 |
|
|
131 |
|
ok(my $node2 = new Search::Estraier::Node( url => "http://localhost:1978/non-existant", croak_on_error => 1 ), "new non-existant"); |
132 |
|
throws_ok { $node->name } qr/port/, 'croak on error'; |
133 |
|
|
134 |
SKIP: { |
SKIP: { |
135 |
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); |
136 |
|
|
137 |
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/$test2_node", $test1_label, 42), "set_link $test2_node ($test1_label) 42"); |
138 |
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, 0), "set_link $test2_node ($test1_label) delete"); |
139 |
} # SKIP 2 |
} # SKIP 2 |
140 |
|
|
141 |
} # SKIP 1 |
} # SKIP 1 |