--- trunk/t/5_Node.t 2006/01/06 12:48:14 50 +++ trunk/t/5_Node.t 2006/01/06 20:58:26 57 @@ -3,7 +3,7 @@ use strict; use blib; -use Test::More tests => 79; +use Test::More tests => 92; use Test::Exception; use Data::Dumper; @@ -14,7 +14,7 @@ # name of node for test my $test_node = 'Search-Estraier'; -ok(my $node = new Search::Estraier::Node($debug), 'new'); +ok(my $node = new Search::Estraier::Node( debug => $debug ), 'new'); isa_ok($node, 'Search::Estraier::Node'); ok($node->set_url('http://localhost:1978/node/searchestraier'), 'set_url'); @@ -75,6 +75,22 @@ ok( ! $node->edit_doc( $doc ), "edit removed"); +my $max = 3; + +ok(my $cond = new Search::Estraier::Condition, 'new cond'); +ok($cond->set_phrase('girl'), 'cond set_phrase'); +ok($cond->set_max($max), "cond set_max $max"); +ok($cond->set_order('@uri ASCD'), 'cond set_order'); +ok($cond->add_attr('@title STRINC Material'), 'cond add_attr'); + +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'); + +ok( my $nrec = $node->search( $cond, 0 ), 'search'); + +isa_ok( $nrec, 'Search::Estraier::NodeResult' ); + +cmp_ok($nrec->doc_num, '==', $max, "doc_num = $max"); + for ( 6 .. 10 ) { my $uri = 'test' . $_; ok( my $id = $node->uri_to_id( $uri ), "uri_to_id $uri"); @@ -95,3 +111,12 @@ ok($v = $node->word_num, "word_num: $v"); ok($v = $node->size, "size: $v"); +ok($node->set_snippet_width( 100, 10, 10 ), "set_snippet_width"); + +# user doesn't exist +ok(! $node->set_user('foobar', 1), 'set_user'); + +ok($node->set_link('test','test', 42), 'set_link test 42'); +ok($node->set_link('test','test', 0), 'set_link delete'); + +diag "over";