3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 98; |
use Test::More tests => 101; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
67 |
my $id; |
my $id; |
68 |
ok($id = $node->uri_to_id( 'data001' ), "uri_to_id = $id"); |
ok($id = $node->uri_to_id( 'data001' ), "uri_to_id = $id"); |
69 |
|
|
70 |
for ( 1 .. 5 ) { |
my $data_max = 5; |
71 |
|
|
72 |
|
for ( 1 .. $data_max ) { |
73 |
ok( $node->out_doc_by_uri( 'test' . $_ ), "out_doc_by_uri test$_"); |
ok( $node->out_doc_by_uri( 'test' . $_ ), "out_doc_by_uri test$_"); |
74 |
} |
} |
75 |
|
|
98 |
|
|
99 |
cmp_ok($nres->doc_num, '==', $max, "doc_num = $max"); |
cmp_ok($nres->doc_num, '==', $max, "doc_num = $max"); |
100 |
|
|
101 |
|
cmp_ok($nres->hits, '==', $data_max, "hits"); |
102 |
|
|
103 |
for ( 6 .. 10 ) { |
for ( 6 .. 10 ) { |
104 |
my $uri = 'test' . $_; |
my $uri = 'test' . $_; |
105 |
ok( my $id = $node->uri_to_id( $uri ), "uri_to_id $uri"); |
ok( my $id = $node->uri_to_id( $uri ), "uri_to_id($uri) = $id"); |
106 |
ok( $node->get_doc( $id ), "get_doc $id"); |
ok( $node->get_doc( $id ), "get_doc $id"); |
107 |
ok( $node->get_doc_by_uri( $uri ), "get_doc_by_uri $uri"); |
ok( $node->get_doc_by_uri( $uri ), "get_doc_by_uri $uri"); |
108 |
cmp_ok( $node->get_doc_attr( $id, '@uri' ), 'eq', $uri, "get_doc_attr $id"); |
cmp_ok( $node->get_doc_attr( $id, '@uri' ), 'eq', $uri, "get_doc_attr $id"); |
138 |
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 => "http://localhost:1978/non-existant", croak_on_error => 1 ), "new non-existant"); |
139 |
throws_ok { $node->name } qr/404/, 'croak on error'; |
throws_ok { $node->name } qr/404/, 'croak on error'; |
140 |
|
|
141 |
# support for undef and 0 values |
# croak_on_error |
142 |
#ok($node = new Search::Estraier::Node( url => "http://localhost:1978/$test1_node", croak_on_error => 1 ), "new $test1_node"); |
ok($node = new Search::Estraier::Node( url => "http://localhost:1978/$test1_node", croak_on_error => 1 ), "new $test1_node"); |
143 |
|
|
144 |
|
ok(! $node->uri_to_id('foobar'), 'uri_to_id without croak'); |
145 |
|
|
146 |
SKIP: { |
SKIP: { |
147 |
skip "no $test2_node in Hyper Estraier, skipping set_link", 2 unless (my $test2_label = $node2->label); |
skip "no $test2_node in Hyper Estraier, skipping set_link", 2 unless (my $test2_label = $node2->label); |