use strict; use Wiki::Toolkit::Setup::SQLite; use File::Temp qw( tempfile ); use OpenGuides; use OpenGuides::Test; use Test::More; eval { require DBD::SQLite; }; if ( $@ ) { my ($error) = $@ =~ /^(.*?)\n/; plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)"; } plan tests => 4; # Clear out the database from any previous runs. OpenGuides::Test::refresh_db(); my $config = OpenGuides::Test->make_basic_config; my $guide = OpenGuides->new( config => $config ); # Print some RSS to a temporary file, and use a 'file://' URL to save faff. my ($fh, $filename) = tempfile( UNLINK => 1 ); while ( my $line = ) { print $fh $line; } close $fh; my $url = 'file://' . $filename; OpenGuides::Test->write_data( guide => $guide, node => "Crabtree Tavern", content => '@RSS ' . $url, ); OpenGuides::Test->write_data( guide => $guide, node => "Crabtree Tavern", content => '@RSS ' . $url, ); my $output = eval { $guide->display_diffs( id => "Crabtree Tavern", version => 1, other_version => 2, return_output => 1, ); }; is( $@, "", "->display_diffs doesn't die when called on a node with RSS feeds in" ); OpenGuides::Test->write_data( guide => $guide, node => "Calthorpe Arms", content => '@INDEX_LIST [[Category Foo]]', ); OpenGuides::Test->write_data( guide => $guide, node => "Calthorpe Arms", content => '@INDEX_LIST [[Category Foo]]', ); $output = eval { $guide->display_diffs( id => "Calthorpe Arms", version => 1, other_version => 2, return_output => 1, ); }; is( $@, "", "...or on a node with INDEX_LIST in" ); OpenGuides::Test->write_data( guide => $guide, node => "Penderel's Oak", content => '@INDEX_LINK [[Category Foo]]', ); OpenGuides::Test->write_data( guide => $guide, node => "Penderel's Oak", content => '@INDEX_LINK [[Category Foo]]', ); $output = eval { $guide->display_diffs( id => "Penderel's Oak", version => 1, other_version => 2, return_output => 1, ); }; is( $@, "", "...or on a node with INDEX_LINK in" ); like( $output, qr|view all pages in category foo|i, "...and index link is correct" ); __DATA__ The Open Guide to London - Kake's Mirror http://london.openguides.org/kakemirror/?RecentChanges 2004-12-14T12:59:42 Buckingham Arms, SW1H 9EU http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=9 extraneous : [bob] 2004-12-12T13:25:27 bob minor 9 updated Buckingham Arms, SW1H 9EU http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=8 [Martin] 2004-12-11T14:05:38 Martin major 8 updated Star Tavern, SW1X 8HT http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=14 De-bobbed the bob bits. [Kake] 2004-12-10T14:29:13 Kake minor 14 updated Star Tavern, SW1X 8HT http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=13 More comments. [Kake] 2004-12-10T14:27:41 Kake major 13 updated Star Tavern, SW1X 8HT http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=12 updated [bob] 2004-12-10T14:18:51 bob minor 12 updated