source: trunk/t/56_diffs_with_macros.t @ 956

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

Complete transition to using skip_all (remove old SKIP blocks).
More verbose reporting for error "require"ing DBD::SQLite.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1use strict;
2use Wiki::Toolkit::Setup::SQLite;
3use File::Temp qw( tempfile );
4use OpenGuides;
5use OpenGuides::Test;
6use Test::More;
7
8eval { require DBD::SQLite; };
9if ( $@ ) {
10    my ($error) = $@ =~ /^(.*?)\n/;
11    plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)";
12}
13
14plan tests => 4;
15
16# Clear out the database from any previous runs.
17unlink "t/node.db";
18unlink <t/indexes/*>;
19Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
20
21my $config = OpenGuides::Test->make_basic_config;
22my $guide = OpenGuides->new( config => $config );
23
24# Print some RSS to a temporary file, and use a 'file://' URL to save faff.
25my ($fh, $filename) = tempfile( UNLINK => 1 );
26while ( my $line = <DATA> ) {
27    print $fh $line;
28}
29close $fh;
30my $url = 'file://' . $filename;
31
32OpenGuides::Test->write_data(
33                               guide   => $guide,
34                               node    => "Crabtree Tavern",
35                               content => '@RSS ' . $url,
36                             );
37OpenGuides::Test->write_data(
38                               guide   => $guide,
39                               node    => "Crabtree Tavern",
40                               content => '@RSS ' . $url,
41                             );
42my $output = eval {
43    $guide->display_diffs(
44                           id            => "Crabtree Tavern",
45                           version       => 1,
46                           other_version => 2,
47                           return_output => 1,
48                         );
49};
50is( $@, "",
51    "->display_diffs doesn't die when called on a node with RSS feeds in" );
52
53OpenGuides::Test->write_data(
54                               guide   => $guide,
55                               node    => "Calthorpe Arms",
56                               content => '@INDEX_LIST [[Category Foo]]',
57                             );
58OpenGuides::Test->write_data(
59                               guide   => $guide,
60                               node    => "Calthorpe Arms",
61                               content => '@INDEX_LIST [[Category Foo]]',
62                             );
63$output = eval {
64    $guide->display_diffs(
65                           id            => "Calthorpe Arms",
66                           version       => 1,
67                           other_version => 2,
68                           return_output => 1,
69                         );
70};
71is( $@, "",
72    "...or on a node with INDEX_LIST in" );
73
74OpenGuides::Test->write_data(
75                               guide   => $guide,
76                               node    => "Penderel's Oak",
77                               content => '@INDEX_LINK [[Category Foo]]',
78                             );
79OpenGuides::Test->write_data(
80                               guide   => $guide,
81                               node    => "Penderel's Oak",
82                               content => '@INDEX_LINK [[Category Foo]]',
83                             );
84$output = eval {
85    $guide->display_diffs(
86                           id            => "Penderel's Oak",
87                           version       => 1,
88                           other_version => 2,
89                           return_output => 1,
90                         );
91};
92is( $@, "",
93    "...or on a node with INDEX_LINK in" );
94like( $output, qr|view all pages in category foo|i,
95      "...and index link is correct" );
96
97
98__DATA__
99<?xml version="1.0" encoding="UTF-8"?>
100
101<rdf:RDF
102 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
103 xmlns="http://purl.org/rss/1.0/"
104 xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
105 xmlns:dc="http://purl.org/dc/elements/1.1/"
106 xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
107 xmlns:wiki="http://purl.org/rss/1.0/modules/wiki/"
108 xmlns:admin="http://webns.net/mvcb/"
109>
110
111<channel rdf:about="http://london.openguides.org/kakemirror/?RecentChanges">
112<title>The Open Guide to London - Kake's Mirror</title>
113<link>http://london.openguides.org/kakemirror/?RecentChanges</link>
114<description></description>
115<dc:date>2004-12-14T12:59:42</dc:date>
116<wiki:interwiki></wiki:interwiki>
117<items>
118 <rdf:Seq>
119  <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=9" />
120  <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=8" />
121  <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=14" />
122  <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=13" />
123  <rdf:li rdf:resource="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=12" />
124 </rdf:Seq>
125</items>
126</channel>
127
128<item rdf:about="http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=9">
129<title>Buckingham Arms, SW1H 9EU</title>
130<link>http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=9</link>
131<description>extraneous : [bob]</description>
132<dc:date>2004-12-12T13:25:27</dc:date>
133<dc:contributor>bob</dc:contributor>
134<wiki:history></wiki:history>
135<wiki:importance>minor</wiki:importance>
136<wiki:version>9</wiki:version>
137<wiki:status>updated</wiki:status>
138<wiki:diff></wiki:diff>
139</item>
140
141<item rdf:about="http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=8">
142<title>Buckingham Arms, SW1H 9EU</title>
143<link>http://london.openguides.org/kakemirror/?id=Buckingham_Arms%2C_SW1H_9EU;version=8</link>
144<description> [Martin]</description>
145<dc:date>2004-12-11T14:05:38</dc:date>
146<dc:contributor>Martin</dc:contributor>
147<wiki:history></wiki:history>
148<wiki:importance>major</wiki:importance>
149<wiki:version>8</wiki:version>
150<wiki:status>updated</wiki:status>
151<wiki:diff></wiki:diff>
152</item>
153
154<item rdf:about="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=14">
155<title>Star Tavern, SW1X 8HT</title>
156<link>http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=14</link>
157<description>De-bobbed the bob bits. [Kake]</description>
158<dc:date>2004-12-10T14:29:13</dc:date>
159<dc:contributor>Kake</dc:contributor>
160<wiki:history></wiki:history>
161<wiki:importance>minor</wiki:importance>
162<wiki:version>14</wiki:version>
163<wiki:status>updated</wiki:status>
164<wiki:diff></wiki:diff>
165</item>
166
167<item rdf:about="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=13">
168<title>Star Tavern, SW1X 8HT</title>
169<link>http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=13</link>
170<description>More comments. [Kake]</description>
171<dc:date>2004-12-10T14:27:41</dc:date>
172<dc:contributor>Kake</dc:contributor>
173<wiki:history></wiki:history>
174<wiki:importance>major</wiki:importance>
175<wiki:version>13</wiki:version>
176<wiki:status>updated</wiki:status>
177<wiki:diff></wiki:diff>
178</item>
179
180<item rdf:about="http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=12">
181<title>Star Tavern, SW1X 8HT</title>
182<link>http://london.openguides.org/kakemirror/?id=Star_Tavern%2C_SW1X_8HT;version=12</link>
183<description>updated [bob]</description>
184<dc:date>2004-12-10T14:18:51</dc:date>
185<dc:contributor>bob</dc:contributor>
186<wiki:history></wiki:history>
187<wiki:importance>minor</wiki:importance>
188<wiki:version>12</wiki:version>
189<wiki:status>updated</wiki:status>
190<wiki:diff></wiki:diff>
191</item>
192
193</rdf:RDF>
Note: See TracBrowser for help on using the repository browser.