mirror of
https://gitlab.silvrtree.co.uk/martind2000/rss-braider.git
synced 2025-02-10 22:29:17 +00:00
Adding test for bad plugin handling
This commit is contained in:
parent
dbbcba5d1a
commit
5080b8cb64
8
examples/plugins/bad_plugin.js
Normal file
8
examples/plugins/bad_plugin.js
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = function (item, itemOptions, source) {
|
||||
|
||||
// This is an intentionally broken plugin for testing.
|
||||
// This doesn't do anything and shouldn't be a template
|
||||
// for other plugins
|
||||
|
||||
return;
|
||||
};
|
35
test/expected_output/fileFeedBadPlugin.xml
Normal file
35
test/expected_output/fileFeedBadPlugin.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
|
||||
<channel>
|
||||
<title><![CDATA[A Feed with no elements]]></title>
|
||||
<description><![CDATA[This feed will have no elements as a result of the filter_all_articles plugin. Used for unit tests.]]></description>
|
||||
<link>http://github.com/dylang/node-rss</link>
|
||||
<generator>rss-braider</generator>
|
||||
<lastBuildDate>Wed, 31 Dec 2014 00:00:01 GMT</lastBuildDate>
|
||||
<item>
|
||||
<title><![CDATA[Rent Hike For Dance Mission Theater Has Artists Worried About Uncertain Future]]></title>
|
||||
<description><![CDATA[<p>Stepping out of BART at 24th and Mission at most hours of the day, one is likely to hear the pulse of African drums, hip-hop or salsa emanating from the second-floor studios of Dance Brigade's Dance Mission Theater. But that music may not continue forever.</p>
|
||||
<p>The performance space and dance school <a href="http://ww2.kqed.org/news/2014/12/20/dance-mission-theater-rent-increase-worries-artists/" target="_self" id="rssmi_more"> ...read more</a>]]></description>
|
||||
<link>http://ww2.kqed.org/news/2014/12/20/dance-mission-theater-rent-increase-worries-artists/</link>
|
||||
<guid isPermaLink="false">http://ww2.kqed.org/arts/2014/12/20/rent-hike-for-dance-mission-theater-has-artists-worried-about-uncertain-future/</guid>
|
||||
<dc:creator><![CDATA[KQED Arts]]></dc:creator>
|
||||
<pubDate>Sat, 20 Dec 2014 09:00:22 GMT</pubDate>
|
||||
</item>
|
||||
<item>
|
||||
<title><![CDATA[Bob Miller: Teasing Science Lessons from Everyday Phenomena]]></title>
|
||||
<description><![CDATA[Until February 5, 2015, you can visit the main branch of the San Francisco Public Library and be momentarily transported through space and time to the early days of the Exploratorium via the life and work of Bob Miller, who died in 2007.]]></description>
|
||||
<link>http://ww2.kqed.org/arts/2014/12/20/bob-miller-teasing-science-lessons-from-everyday-phenomena/</link>
|
||||
<guid isPermaLink="false">http://ww2.kqed.org/arts/?p=10220517</guid>
|
||||
<dc:creator><![CDATA[Sarah Hotchkiss]]></dc:creator>
|
||||
<pubDate>Sat, 20 Dec 2014 14:00:47 GMT</pubDate>
|
||||
</item>
|
||||
<item>
|
||||
<title><![CDATA[Light Art Brings Holiday Glow to Darkest Nights]]></title>
|
||||
<description><![CDATA[In the dark of winter, San Franciscans with an urge to celebrate the light can visit a new wealth of illuminated art installations. This video tour offers a preview of some of the more dazzling works.]]></description>
|
||||
<link>http://ww2.kqed.org/arts/2014/12/21/on-darkest-nights-illuminated-art-brings-holiday-glow/</link>
|
||||
<guid isPermaLink="false">http://ww2.kqed.org/arts/?p=10231062</guid>
|
||||
<dc:creator><![CDATA[KQED Arts]]></dc:creator>
|
||||
<pubDate>Sun, 21 Dec 2014 14:00:08 GMT</pubDate>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
17
test/feeds/sample_feed_bad_plugin.js
Normal file
17
test/feeds/sample_feed_bad_plugin.js
Normal file
@ -0,0 +1,17 @@
|
||||
var feed = {
|
||||
"feed_name" : "no_elements",
|
||||
// "plugins" : ['bad_plugin'], // Intentionally bad plugin for testing
|
||||
"meta" : {
|
||||
"title" : "A Feed with no elements",
|
||||
"description" : "This feed will have no elements as a result of the filter_all_articles plugin. Used for unit tests.",
|
||||
"url" : "http://rss.nytimes.com/services/xml/rss/nyt/Technology.xml",
|
||||
},
|
||||
"sources" : [
|
||||
{
|
||||
"name" : "sample_source",
|
||||
"count" : 3,
|
||||
"file_path" : __dirname + "/../input_files/sample_feed.xml",
|
||||
}
|
||||
]
|
||||
};
|
||||
exports.feed = feed;
|
@ -131,4 +131,27 @@ test('filter all articles out using plugin', function(t) {
|
||||
// console.log(data);
|
||||
t.equal(data, expectedOutput.emptyFeed);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test("Don't break when a filter fails and returns null", function(t) {
|
||||
t.plan(1);
|
||||
var feeds = {};
|
||||
feeds.sample_feed = require("./feeds/sample_feed_bad_plugin").feed;
|
||||
var braider_options = {
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
date_sort_order : "asc",
|
||||
plugins_directories : [__dirname + '/../examples/plugins/']
|
||||
};
|
||||
var rss_braider = RssBraider.createClient(braider_options);
|
||||
rss_braider.logger.level('info');
|
||||
|
||||
rss_braider.processFeed('sample_feed', 'rss', function(err, data){
|
||||
if (err) {
|
||||
return t.fail(err);
|
||||
}
|
||||
// console.log(data);
|
||||
t.equal(data, expectedOutput.fileFeedBadPlugin);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user