3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 79; |
use Test::More tests => 92; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
14 |
# name of node for test |
# name of node for test |
15 |
my $test_node = 'Search-Estraier'; |
my $test_node = 'Search-Estraier'; |
16 |
|
|
17 |
ok(my $node = new Search::Estraier::Node($debug), 'new'); |
ok(my $node = new Search::Estraier::Node( debug => $debug ), 'new'); |
18 |
isa_ok($node, 'Search::Estraier::Node'); |
isa_ok($node, 'Search::Estraier::Node'); |
19 |
|
|
20 |
ok($node->set_url('http://localhost:1978/node/searchestraier'), 'set_url'); |
ok($node->set_url('http://localhost:1978/node/searchestraier'), 'set_url'); |
75 |
|
|
76 |
ok( ! $node->edit_doc( $doc ), "edit removed"); |
ok( ! $node->edit_doc( $doc ), "edit removed"); |
77 |
|
|
78 |
|
my $max = 3; |
79 |
|
|
80 |
|
ok(my $cond = new Search::Estraier::Condition, 'new cond'); |
81 |
|
ok($cond->set_phrase('girl'), 'cond set_phrase'); |
82 |
|
ok($cond->set_max($max), "cond set_max $max"); |
83 |
|
ok($cond->set_order('@uri ASCD'), 'cond set_order'); |
84 |
|
ok($cond->add_attr('@title STRINC Material'), 'cond add_attr'); |
85 |
|
|
86 |
|
cmp_ok($node->cond_to_query( $cond ), 'eq' , 'phrase=girl&attr1=%40title%20STRINC%20Material&order=%40uri%20ASCD&max='.$max.'&wwidth=480&hwidth=96&awidth=96', 'cond_to_query'); |
87 |
|
|
88 |
|
ok( my $nrec = $node->search( $cond, 0 ), 'search'); |
89 |
|
|
90 |
|
isa_ok( $nrec, 'Search::Estraier::NodeResult' ); |
91 |
|
|
92 |
|
cmp_ok($nrec->doc_num, '==', $max, "doc_num = $max"); |
93 |
|
|
94 |
for ( 6 .. 10 ) { |
for ( 6 .. 10 ) { |
95 |
my $uri = 'test' . $_; |
my $uri = 'test' . $_; |
96 |
ok( my $id = $node->uri_to_id( $uri ), "uri_to_id $uri"); |
ok( my $id = $node->uri_to_id( $uri ), "uri_to_id $uri"); |
111 |
ok($v = $node->word_num, "word_num: $v"); |
ok($v = $node->word_num, "word_num: $v"); |
112 |
ok($v = $node->size, "size: $v"); |
ok($v = $node->size, "size: $v"); |
113 |
|
|
114 |
|
ok($node->set_snippet_width( 100, 10, 10 ), "set_snippet_width"); |
115 |
|
|
116 |
|
# user doesn't exist |
117 |
|
ok(! $node->set_user('foobar', 1), 'set_user'); |
118 |
|
|
119 |
|
ok($node->set_link('test','test', 42), 'set_link test 42'); |
120 |
|
ok($node->set_link('test','test', 0), 'set_link delete'); |
121 |
|
|
122 |
|
diag "over"; |