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

Last change on this file since 565 was 565, checked in by kake, 17 years ago

Take out some more common testing code into OpenGuides::Test - make_basic_config

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