3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 5; |
use Test::More tests => 12; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
10 |
BEGIN { use_ok('Search::Estraier') }; |
BEGIN { use_ok('Search::Estraier') }; |
11 |
|
|
12 |
ok(my $node = new Search::Estraier::Node, 'new'); |
# name of node for test |
13 |
|
my $test_node = 'Search-Estraier'; |
14 |
|
|
15 |
|
ok(my $node = new Search::Estraier::Node(1), 'new'); |
16 |
isa_ok($node, 'Search::Estraier::Node'); |
isa_ok($node, 'Search::Estraier::Node'); |
17 |
|
|
18 |
ok($node->set_url('http://localhost:1978/'), 'set_url'); |
ok($node->set_url('http://localhost:1978/'), 'set_url'); |
19 |
|
|
20 |
ok($node->set_proxy('proxy.example.com', 8080), 'set_proxy'); |
ok($node->set_proxy('', 8080), 'set_proxy'); |
21 |
|
throws_ok {$node->set_proxy('proxy.example.com', 'foo') } qr/port/, 'set_proxy port NaN'; |
22 |
|
|
23 |
|
ok($node->set_timeout(42), 'set_timeout'); |
24 |
|
throws_ok {$node->set_timeout('foo') } qr/timeout/, 'set_timeout NaN'; |
25 |
|
|
26 |
|
ok($node->set_auth('admin','admin'), 'set_auth'); |
27 |
|
|
28 |
|
cmp_ok($node->status, '==', -1, 'status'); |
29 |
|
|
30 |
|
my @res = ( -1, 200 ); |
31 |
|
|
32 |
|
my $nodelist; |
33 |
|
foreach my $url (qw{?action=nodelist http://localhost:1978/master?action=nodelist}) { |
34 |
|
cmp_ok( |
35 |
|
$node->shuttle_url( $url, 'text/plain', undef, \$nodelist) |
36 |
|
,'==', shift @res, 'nodelist'); |
37 |
|
} |
38 |
|
|
39 |
|
my $draft = <<'_END_OF_DRAFT_'; |
40 |
|
@uri=data001 |
41 |
|
@title=Material Girl |
42 |
|
|
43 |
|
Living in a material world |
44 |
|
And I am a material girl |
45 |
|
You know that we are living in a material world |
46 |
|
And I am a material girl |
47 |
|
_END_OF_DRAFT_ |
48 |
|
|
49 |
|
diag "draft:\n$draft"; |