--- trunk/t/5_Node.t 2006/05/16 16:01:09 153 +++ trunk/t/5_Node.t 2006/08/06 18:15:11 173 @@ -3,7 +3,7 @@ use strict; use blib; -my $tests = 269; +my $tests = 280; use Test::More; use Test::Exception; @@ -157,6 +157,8 @@ my $id; ok($id = $node->uri_to_id( 'data0' ), "uri_to_id(data0)"); +throws_ok { $node->get_doc( 'foo') } qr/id must be number/, 'croak on non-number'; + ok($doc = $node->get_doc( $id ), "get_doc($id) for edit"); $doc->add_attr('foo', 'bar'); #diag Dumper($doc); @@ -171,6 +173,9 @@ ok( ! $node->edit_doc( $doc ), "edit_doc of removed doc"); +my $cache; +ok($cache = $node->cacheusage, "cacheusage: $cache"); + my $delete_num = 5; for ( 1 .. $delete_num ) { @@ -188,8 +193,9 @@ 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'); +ok($cond->set_mask(qw/1 2/), 'cond set_mask'); -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'); +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&mask=6', 'cond_to_query'); ok( my $nres = $node->search( $cond, 0 ), 'search'); @@ -229,6 +235,9 @@ ok(my $hints = $nres->hints, 'hints'); diag Dumper($hints) if ($debug); +foreach my $h (qw/TIME DOCNUM VERSION NODE HIT WORDNUM/) { + ok(defined( $nres->hint($h) ), "have hint $h"); +} ok($node->_set_info, "refresh _set_info"); @@ -244,6 +253,9 @@ # test skip my $skip = int($max / 2) || die "skip is zero, can't test"; ok($cond->set_skip( $skip ), "cond set_skip($skip)"); +cmp_ok($cond->skip, '==', $skip, "skip is $skip"); + +like($node->cond_to_query( $cond ), qr/skip=$skip/, 'cond_to_query have skip'); ok( $nres = $node->search( $cond, 0 ), 'search'); isa_ok( $nres, 'Search::Estraier::NodeResult' ); @@ -251,7 +263,7 @@ cmp_ok($nres->hits, '==', $doc_num2, "nres->hits $doc_num2"); for my $i ( 0 .. ($nres->doc_num - 1) ) { - my $uri = 'test' . ($i + $delete_num + 1); + my $uri = 'test' . ($i + $delete_num + $skip + 1); ok( my $rdoc = $nres->get_doc( $i ), "nres->get_doc $i"); if ($rdoc) { cmp_ok( $rdoc->attr('@uri'), 'eq', $uri, "\@uri = $uri"); @@ -262,7 +274,7 @@ # user doesn't exist -ok(! $node->set_user('foobar', 1), 'set_user'); +ok($node->set_user('foobar', 1), 'set_user'); ok(my $node2 = new Search::Estraier::Node( "$estmaster_uri/node/$test2_node" ), "new $test2_node"); ok($node2->set_auth('admin','admin'), "set_auth $test2_node"); @@ -279,7 +291,7 @@ # test users -ok(! $node->admins, 'no admins'); +ok($node->admins, 'have admins'); ok(! $node->guests, 'no guests'); @@ -301,7 +313,7 @@ ok($msg = $node->master( action => 'nodeclr', name => $node->name, -), "nodeclr $node->name: $msg"); +), "nodeclr " . $node->name . ": $msg"); cmp_ok($node->doc_num, '==', 0, 'no documents');