3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 35; |
use Test::More tests => 79; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
51 |
#diag "draft:\n$draft"; |
#diag "draft:\n$draft"; |
52 |
ok(my $doc = new Search::Estraier::Document($draft), 'new doc from draft'); |
ok(my $doc = new Search::Estraier::Document($draft), 'new doc from draft'); |
53 |
|
|
54 |
|
ok( $node->put_doc($doc), "put_doc data001"); |
55 |
|
|
56 |
for ( 1 .. 10 ) { |
for ( 1 .. 10 ) { |
57 |
$doc->add_attr('@uri', 'test' . $_); |
$doc->add_attr('@uri', 'test' . $_); |
58 |
ok( $node->put_doc($doc), "put_doc test$_"); |
ok( $node->put_doc($doc), "put_doc test$_"); |
59 |
#diag $doc->dump_draft; |
#diag $doc->dump_draft; |
60 |
} |
} |
61 |
|
|
62 |
ok( $node->out_doc( 0 ), 'out_doc'); |
my $id; |
63 |
|
ok($id = $node->uri_to_id( 'data001' ), "uri_to_id = $id"); |
64 |
|
|
65 |
for ( 1 .. 10 ) { |
for ( 1 .. 5 ) { |
66 |
ok( $node->out_doc_by_uri( 'test' .$_ ), "out_doc_by_uri test$_"); |
ok( $node->out_doc_by_uri( 'test' . $_ ), "out_doc_by_uri test$_"); |
67 |
} |
} |
68 |
|
|
69 |
$doc->add_attr('@uri', 'data001'); |
ok($doc = $node->get_doc( $id ), 'get_doc for edit'); |
70 |
$doc->add_attr('foo', 'bar'); |
$doc->add_attr('foo', 'bar'); |
71 |
|
#diag Dumper($doc); |
72 |
ok( $node->edit_doc( $doc ), 'edit_doc'); |
ok( $node->edit_doc( $doc ), 'edit_doc'); |
73 |
|
|
74 |
|
ok( $node->out_doc( $id ), "out_doc $id"); |
75 |
|
|
76 |
|
ok( ! $node->edit_doc( $doc ), "edit removed"); |
77 |
|
|
78 |
|
for ( 6 .. 10 ) { |
79 |
|
my $uri = 'test' . $_; |
80 |
|
ok( my $id = $node->uri_to_id( $uri ), "uri_to_id $uri"); |
81 |
|
ok( $node->get_doc( $id ), "get_doc $id"); |
82 |
|
ok( $node->get_doc_by_uri( $uri ), "get_doc_by_uri $uri"); |
83 |
|
cmp_ok( $node->get_doc_attr( $id, '@uri' ), 'eq', $uri, "get_doc_attr $id"); |
84 |
|
cmp_ok( $node->get_doc_attr_by_uri( $uri, '@uri' ), 'eq', $uri, "get_doc_attr $id"); |
85 |
|
ok( my $k = $node->etch_doc( $id ), "etch_doc_by_uri $uri"); |
86 |
|
ok( my $k2 = $node->etch_doc_by_uri( $uri ), "etch_doc_by_uri $uri"); |
87 |
|
#diag Dumper($k, $k2); |
88 |
|
ok( eq_hash( $k, $k2 ), "keywords"); |
89 |
|
} |
90 |
|
|
91 |
|
my $v; |
92 |
|
ok($v = $node->name, "name: $v"); |
93 |
|
ok($v = $node->label, "label: $v"); |
94 |
|
ok($v = $node->doc_num, "doc_num: $v"); |
95 |
|
ok($v = $node->word_num, "word_num: $v"); |
96 |
|
ok($v = $node->size, "size: $v"); |
97 |
|
|