source: trunk/t/52_display_diffs.t @ 949

Last change on this file since 949 was 949, checked in by Earle Martin, 15 years ago

Use skip_all for tests relying entirely on SQLite, instead of issuing skip commands with duplicate test counts and causing maintenance overhead.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1use strict;
2use Wiki::Toolkit::Setup::SQLite;
3use OpenGuides;
4use OpenGuides::Test;
5use Test::More;
6
7eval { require DBD::SQLite; };
8
9if ($@) {
10    plan skip_all => "DBD::SQLite not installed - no database to test with";
11} else {
12    plan tests => 5;
13}
14
15
16SKIP: {
17    Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
18    my $config = OpenGuides::Test->make_basic_config;
19    my $guide = OpenGuides->new( config => $config );
20    my $wiki = $guide->wiki;
21
22    # Clear out the database from any previous runs.
23    foreach my $del_node ( $wiki->list_all_nodes ) {
24        print "# Deleting node $del_node\n";
25        $wiki->delete_node( $del_node ) or die "Can't delete $del_node";
26    }
27
28    $wiki->write_node( "I Like Pie", "Best pie is meat pie." )
29      or die "Couldn't write node";
30    my %data = $wiki->retrieve_node( "I Like Pie" );
31    $wiki->write_node( "I Like Pie", "Best pie is apple pie.",
32                       $data{checksum} )
33      or die "Couldn't write node";
34    %data = $wiki->retrieve_node( "I Like Pie" );
35    $wiki->write_node( "I Like Pie", "Best pie is lentil pie.",
36                       $data{checksum} )
37      or die "Couldn't write node";
38
39    my $output = eval {
40        $guide->display_diffs(
41                               id            => "I Like Pie",
42                               version       => 3,
43                               other_version => 2,
44                               return_output => 1,
45                             );
46    };
47    is( $@, "", "->display_diffs doesn't die" );
48    like( $output,
49          qr/differences between version 2 and version 3/i,
50          "...version numbers included in output" );
51    like( $output, qr|<span class="node_name">I Like Pie</span>|,
52          "...node name inlined in output" );
53    unlike( $output, qr/contents are identical/i,
54            "...'contents are identical' not printed when contents differ" );
55    like( $output, qr/<th.*Version\s+2.*Version\s+3.*apple.*lentil/s,
56          "...versions are right way round" );
57}
Note: See TracBrowser for help on using the repository browser.