source: wiki-toolkit/trunk/t/401_null_change.t @ 477

Last change on this file since 477 was 477, checked in by kake, 13 years ago

Applied a modified version of tgj's patch (OpenGuides? ticket #23). Also fixed minor POD error while I was at it.

File size: 1.5 KB
Line 
1use strict;
2use Wiki::Toolkit::TestLib;
3use Test::More;
4
5if ( scalar @Wiki::Toolkit::TestLib::wiki_info == 0 ) {
6    plan skip_all => "no backends configured";
7} else {
8    plan tests => ( 4 * scalar @Wiki::Toolkit::TestLib::wiki_info );
9}
10
11my $iterator = Wiki::Toolkit::TestLib->new_wiki_maker;
12
13my $metadata_orig = { foo => [ 7 ], bar => [ 9 ] };
14my $metadata_changed = { foo => [ "changed" ], bar => [ 9 ] };
15my $content_orig = "Node content.";
16my $content_changed = "Node content -- changed";
17my $id = "A Node";
18
19while ( my $wiki = $iterator->new_wiki ) {
20    $wiki->write_node($id, $content_orig, undef, $metadata_orig );
21
22    my %node_data = $wiki->retrieve_node($id);
23
24    is( $wiki->write_node(
25            $id, $content_orig, $node_data{checksum},
26            $metadata_orig,
27        ),
28        -1,
29        "refuses to update if new content and metadata is the same",
30    );
31
32    %node_data = $wiki->retrieve_node($id);
33
34    ok( $wiki->write_node(
35            $id, $content_orig, $node_data{checksum},
36            $metadata_changed,
37        ) >= 1,
38        "still updates if metadata is different",
39    );
40   
41    %node_data = $wiki->retrieve_node($id);
42
43    ok( $wiki->write_node(
44            $id, $content_changed, $node_data{checksum},
45            $metadata_changed,
46        ) >= 1,
47        "still updates if content is different",
48    );
49
50    %node_data = $wiki->retrieve_node($id);
51
52    is( $wiki->write_node(
53            $id, $content_changed, $node_data{checksum},
54            $metadata_changed,
55        ),
56        -1,
57        "... and refuses again when nothing changed",
58    );
59}
Note: See TracBrowser for help on using the repository browser.