3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 92; |
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 = 'Search-Estraier'; |
my $test1_node = 'test1'; |
16 |
|
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/searchestraier'), 'set_url'); |
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'; |
30 |
|
|
31 |
cmp_ok($node->status, '==', -1, 'status'); |
cmp_ok($node->status, '==', -1, 'status'); |
32 |
|
|
33 |
|
SKIP: { |
34 |
|
|
35 |
|
skip "no $test1_node node in Hyper Estraier", 87, unless($node->name); |
36 |
|
|
37 |
my @res = ( -1, 200 ); |
my @res = ( -1, 200 ); |
38 |
|
|
39 |
my $nodelist; |
my $nodelist; |
109 |
ok( eq_hash( $k, $k2 ), "keywords"); |
ok( eq_hash( $k, $k2 ), "keywords"); |
110 |
} |
} |
111 |
|
|
112 |
|
ok($node->_set_info, "refresh _set_info"); |
113 |
|
|
114 |
my $v; |
my $v; |
115 |
ok($v = $node->name, "name: $v"); |
ok($v = $node->name, "name: $v"); |
116 |
ok($v = $node->label, "label: $v"); |
ok($v = $node->label, "label: $v"); |
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($node->set_link('test','test', 42), 'set_link test 42'); |
ok(my $node1 = new Search::Estraier::Node( "http://localhost:1978/node/$test2_node" ), "new $test2_node"); |
127 |
ok($node->set_link('test','test', 0), 'set_link delete'); |
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: { |
135 |
|
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/$test2_node", $test1_label, 42), "set_link $test2_node ($test1_label) 42"); |
138 |
|
ok($node->set_link("http://localhost:1978/node/$test2_node", $test1_label, 0), "set_link $test2_node ($test1_label) delete"); |
139 |
|
} # SKIP 2 |
140 |
|
|
141 |
|
} # SKIP 1 |
142 |
|
|
143 |
diag "over"; |
diag "over"; |