3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 246; |
use Test::More tests => 270; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
32 |
|
|
33 |
# test master functionality |
# test master functionality |
34 |
|
|
35 |
#diag "not testing shutdown\n"; |
diag("node->master shutdown not tested"); |
36 |
|
|
37 |
my $msg; |
diag("node->master backup not tested"); |
|
|
|
|
#diag "not testing backup\n"; |
|
38 |
|
|
39 |
ok(my @users = $node->master( action => 'userlist' ), 'userlist'); |
ok(my @users = $node->master( action => 'userlist' ), 'userlist'); |
40 |
|
|
48 |
misc => 'test user', |
misc => 'test user', |
49 |
}; |
}; |
50 |
|
|
51 |
|
my $msg; |
52 |
ok($msg = $node->master( |
ok($msg = $node->master( |
53 |
action => 'useradd', |
action => 'useradd', |
54 |
%{ $user }, |
%{ $user }, |
106 |
} |
} |
107 |
|
|
108 |
ok($msg = $node->master( |
ok($msg = $node->master( |
|
action => 'nodeclr', |
|
|
name => $temp_node, |
|
|
), "nodeclr $temp_node: $msg"); |
|
|
|
|
|
ok($msg = $node->master( |
|
109 |
action => 'nodedel', |
action => 'nodedel', |
110 |
name => $temp_node, |
name => $temp_node, |
111 |
), "nodedel $temp_node: $msg"); |
), "nodedel $temp_node: $msg"); |
133 |
$doc->add_attr('@uri', 'test' . $_); |
$doc->add_attr('@uri', 'test' . $_); |
134 |
ok( $node->put_doc($doc), "put_doc test$_"); |
ok( $node->put_doc($doc), "put_doc test$_"); |
135 |
#diag $doc->dump_draft; |
#diag $doc->dump_draft; |
136 |
|
cmp_ok( $node->doc_num, '==', ($_ + 1), "node->doc_num " . ($_ + 1)); |
137 |
} |
} |
138 |
|
|
139 |
ok(! $node->uri_to_id( 'does-not-exists' ), "non-existant uri_to_id"); |
ok(! $node->uri_to_id( 'does-not-exists' ), "non-existant uri_to_id"); |
146 |
#diag Dumper($doc); |
#diag Dumper($doc); |
147 |
ok( $node->edit_doc( $doc ), 'edit_doc'); |
ok( $node->edit_doc( $doc ), 'edit_doc'); |
148 |
|
|
149 |
|
my $doc_num; |
150 |
|
ok( $doc_num = $node->doc_num, "node->doc_num $doc_num"); |
151 |
|
|
152 |
ok( $node->out_doc( $id ), "out_doc($id)"); |
ok( $node->out_doc( $id ), "out_doc($id)"); |
153 |
|
|
154 |
ok( ! $node->edit_doc( $doc ), "edit_doc of removed doc"); |
cmp_ok( $node->doc_num, '==', --$doc_num, "node->doc_num " . $doc_num); |
155 |
|
|
156 |
my $doc_num; |
ok( ! $node->edit_doc( $doc ), "edit_doc of removed doc"); |
|
ok( $doc_num = $node->doc_num, "node->doc_num $doc_num"); |
|
157 |
|
|
158 |
my $delete_num = 5; |
my $delete_num = 5; |
159 |
|
|
160 |
for ( 1 .. $delete_num ) { |
for ( 1 .. $delete_num ) { |
161 |
ok( $node->out_doc_by_uri( 'test' . $_ ), "out_doc_by_uri test$_"); |
ok( $node->out_doc_by_uri( 'test' . $_ ), "out_doc_by_uri test$_"); |
162 |
|
cmp_ok( $node->doc_num, '==', $doc_num - $_, "node->doc_num " . ($doc_num - $_)); |
163 |
} |
} |
164 |
|
|
|
ok($msg = $node->master( action => 'sync' ), "sync: $msg"); |
|
|
|
|
165 |
my $doc_num2 = $doc_num - $delete_num; |
my $doc_num2 = $doc_num - $delete_num; |
166 |
cmp_ok($node->doc_num, '==', $doc_num2, "node->doc_num $doc_num2"); |
cmp_ok($node->doc_num, '==', $doc_num2, "node->doc_num $doc_num2"); |
167 |
|
|
198 |
ok( my $k = $rdoc->keywords( $id ), "rdoc keywords"); |
ok( my $k = $rdoc->keywords( $id ), "rdoc keywords"); |
199 |
} else { |
} else { |
200 |
ok( ! $nres->get_doc( $i ), "nres->get_doc doesn't exist"); |
ok( ! $nres->get_doc( $i ), "nres->get_doc doesn't exist"); |
|
|
|
201 |
} |
} |
202 |
|
|
203 |
ok( my $id = $node->uri_to_id( $uri ), "uri_to_id($uri)"); |
ok( my $id = $node->uri_to_id( $uri ), "uri_to_id($uri)"); |
282 |
like($links->[0], qr/^$link_url/, 'link correct'); |
like($links->[0], qr/^$link_url/, 'link correct'); |
283 |
ok($node->set_link("http://localhost:1978/node/$test2_node", $test2_label, 0), "set_link $test2_node ($test2_label) delete"); |
ok($node->set_link("http://localhost:1978/node/$test2_node", $test2_label, 0), "set_link $test2_node ($test2_label) delete"); |
284 |
|
|
285 |
|
ok($msg = $node->master( |
286 |
|
action => 'nodeclr', |
287 |
|
name => $node->name, |
288 |
|
), "nodeclr $node->name: $msg"); |
289 |
|
|
290 |
|
cmp_ok($node->doc_num, '==', 0, 'no documents'); |
291 |
|
|
292 |
# cleanup test nodes |
# cleanup test nodes |
293 |
foreach my $node_name ( $test1_node , $test2_node ) { |
foreach my $node_name ( $test1_node , $test2_node ) { |
294 |
ok($msg = $node->master( |
ok($msg = $node->master( |
348 |
name => $node_name, |
name => $node_name, |
349 |
), "nodedel $node_name: $msg"); |
), "nodedel $node_name: $msg"); |
350 |
|
|
351 |
|
ok($msg = $node->master( action => 'sync' ), "sync: $msg"); |
352 |
|
|
353 |
diag "over"; |
diag "over"; |