--- trunk/t/5_Node.t 2006/01/05 22:27:03 38 +++ trunk/t/5_Node.t 2006/01/06 01:40:04 46 @@ -3,19 +3,21 @@ use strict; use blib; -use Test::More tests => 12; +use Test::More tests => 52; use Test::Exception; use Data::Dumper; BEGIN { use_ok('Search::Estraier') }; +my $debug = 0; + # name of node for test my $test_node = 'Search-Estraier'; -ok(my $node = new Search::Estraier::Node, 'new'); +ok(my $node = new Search::Estraier::Node($debug), 'new'); isa_ok($node, 'Search::Estraier::Node'); -ok($node->set_url('http://localhost:1978/'), 'set_url'); +ok($node->set_url('http://localhost:1978/node/searchestraier'), 'set_url'); ok($node->set_proxy('', 8080), 'set_proxy'); throws_ok {$node->set_proxy('proxy.example.com', 'foo') } qr/port/, 'set_proxy port NaN'; @@ -23,14 +25,14 @@ ok($node->set_timeout(42), 'set_timeout'); throws_ok {$node->set_timeout('foo') } qr/timeout/, 'set_timeout NaN'; -ok($node->set_auth('foo','bar'), 'set_auth'); +ok($node->set_auth('admin','admin'), 'set_auth'); cmp_ok($node->status, '==', -1, 'status'); my @res = ( -1, 200 ); my $nodelist; -foreach my $url (qw{?action=nodelist http://localhost:1978/master_ui?action=nodelist}) { +foreach my $url (qw{?action=nodelist http://localhost:1978/master?action=nodelist}) { cmp_ok( $node->shuttle_url( $url, 'text/plain', undef, \$nodelist) ,'==', shift @res, 'nodelist'); @@ -46,4 +48,33 @@ And I am a material girl _END_OF_DRAFT_ -diag "draft:\n$draft"; +#diag "draft:\n$draft"; +ok(my $doc = new Search::Estraier::Document($draft), 'new doc from draft'); + +ok( $node->put_doc($doc), "put_doc data001"); + +for ( 1 .. 10 ) { + $doc->add_attr('@uri', 'test' . $_); + ok( $node->put_doc($doc), "put_doc test$_"); + #diag $doc->dump_draft; +} + +ok(my $id = $node->uri_to_id( 'data001' ), 'uri_to_id'); + +ok( $node->out_doc( $id ), "out_doc $id"); + +for ( 1 .. 5 ) { + ok( $node->out_doc_by_uri( 'test' . $_ ), "out_doc_by_uri test$_"); +} + +$doc->add_attr('@uri', 'data001'); +$doc->add_attr('foo', 'bar'); +ok( $node->edit_doc( $doc ), 'edit_doc'); + +for ( 6 .. 10 ) { + my $uri = 'test' . $_; + ok( my $id = $node->uri_to_id( $uri ), "uri_to_id $uri"); + ok( $node->get_doc( $id ), "get_doc $id"); + ok( $node->get_doc_by_uri( $uri ), "get_doc_by_uri $uri"); + ok( my $k = $node->etch_doc_by_uri( $uri ), "etch_doc_by_uri $uri"); +}