More unit tests.
This commit is contained in:
parent
5598740fd5
commit
68e9098d83
@ -80,9 +80,7 @@ mod tests {
|
||||
fn test_parse_podcast_intercepted() {
|
||||
let file = File::open("tests/feeds/Intercepted.xml").unwrap();
|
||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||
let uri = "https://feeds.feedburner.com/InterceptedWithJeremyScahill";
|
||||
|
||||
// println!("{:#?}", channel);
|
||||
let descr = "The people behind The Intercept’s fearless reporting and incisive commentary—Jeremy Scahill, Glenn Greenwald, Betsy Reed and others—discuss the crucial issues of our time: national security, civil liberties, foreign policy, and criminal justice. Plus interviews with artists, thinkers, and newsmakers who challenge our preconceptions about the world we live in.";
|
||||
let pd = parse_podcast(&channel, 0).unwrap();
|
||||
|
||||
@ -96,9 +94,7 @@ mod tests {
|
||||
fn test_parse_podcast_breakthrough() {
|
||||
let file = File::open("tests/feeds/TheBreakthrough.xml").unwrap();
|
||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||
let uri = "http://feeds.propublica.org/propublica/main";
|
||||
|
||||
// println!("{:#?}", channel);
|
||||
let descr = "Latest Articles and Investigations from ProPublica, an independent, non-profit newsroom that produces investigative journalism in the public interest.";
|
||||
let pd = parse_podcast(&channel, 0).unwrap();
|
||||
|
||||
@ -123,9 +119,7 @@ mod tests {
|
||||
fn test_parse_podcast_lup() {
|
||||
let file = File::open("tests/feeds/LinuxUnplugged.xml").unwrap();
|
||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||
let uri = "http://feeds.feedburner.com/linuxunplugged";
|
||||
|
||||
// println!("{:#?}", channel);
|
||||
let descr = "An open show powered by community LINUX Unplugged takes the best attributes of open collaboration and focuses them into a weekly lifestyle show about Linux.";
|
||||
let pd = parse_podcast(&channel, 0).unwrap();
|
||||
|
||||
@ -140,28 +134,42 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_podcast_r4explanation() {
|
||||
let file = File::open("tests/feeds/R4Explanation.xml").unwrap();
|
||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||
|
||||
let pd = parse_podcast(&channel, 0).unwrap();
|
||||
let descr = "A weekly discussion of Rust RFCs";
|
||||
|
||||
assert_eq!(pd.title, "Request For Explanation".to_string());
|
||||
assert_eq!(pd.link, "https://request-for-explanation.github.io/podcast/".to_string());
|
||||
assert_eq!(pd.description, descr.to_string());
|
||||
assert_eq!(
|
||||
pd.image_uri,
|
||||
Some(
|
||||
"https://request-for-explanation.github.io/podcast/podcast.png".to_string(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_episode_intercepted() {
|
||||
let file = File::open("tests/feeds/Intercepted.xml").unwrap();
|
||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||
|
||||
let firstitem = channel.items().first().unwrap();
|
||||
// println!("{:#?}", firstitem);
|
||||
let descr = "NSA whistleblower Edward Snowden discusses the massive Equifax data breach and allegations of Russian interference in the US election. Commentator Shaun King explains his call for a boycott of the NFL and talks about his campaign to bring violent neo-Nazis to justice. Rapper Open Mike Eagle performs.";
|
||||
let i = parse_episode(&firstitem, 0).unwrap();
|
||||
|
||||
assert_eq!(i.title, Some("The Super Bowl of Racism"));
|
||||
assert_eq!(
|
||||
i.uri,
|
||||
Some("http://traffic.megaphone.fm/PPY6458293736.mp3")
|
||||
);
|
||||
assert_eq!(i.uri, Some("http://traffic.megaphone.fm/PPY6458293736.mp3"));
|
||||
assert_eq!(i.description, Some(descr));
|
||||
assert_eq!(i.length, Some(66738886));
|
||||
assert_eq!(i.guid, Some("7df4070a-9832-11e7-adac-cb37b05d5e24"));
|
||||
assert_eq!(i.published_date, Some("Wed, 13 Sep 2017 10:00:00 -0000"));
|
||||
|
||||
let second = channel.items().iter().nth(1).unwrap();
|
||||
// println!("{:#?}", second);
|
||||
let i2 = parse_episode(&second, 0).unwrap();
|
||||
|
||||
let descr2 = "This week on Intercepted: Jeremy gives an update on the aftermath of Blackwater’s 2007 massacre of Iraqi civilians. Intercept reporter Lee Fang lays out how a network of libertarian think tanks called the Atlas Network is insidiously shaping political infrastructure in Latin America. We speak with attorney and former Hugo Chavez adviser Eva Golinger about the Venezuela\'s political turmoil.And we hear Claudia Lizardo of the Caracas-based band, La Pequeña Revancha, talk about her music and hopes for Venezuela.";
|
||||
@ -176,7 +184,6 @@ mod tests {
|
||||
assert_eq!(i2.length, Some(67527575));
|
||||
assert_eq!(i2.guid, Some("7c207a24-e33f-11e6-9438-eb45dcf36a1d"));
|
||||
assert_eq!(i2.published_date, Some("Wed, 09 Aug 2017 10:00:00 -0000"));
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -214,15 +221,99 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
i2.title,
|
||||
Some("Failing Charter Schools Have a Reincarnation Plan")
|
||||
);
|
||||
assert_eq!(
|
||||
i2.uri,
|
||||
Some("http://tracking.feedpress.it/link/9499/6841866")
|
||||
);
|
||||
// Too long
|
||||
// assert_eq!(i2.description, Some(descr2));
|
||||
assert_eq!(i2.length, None);
|
||||
assert_eq!(
|
||||
i2.guid,
|
||||
Some(
|
||||
"Failing Charter Schools Have a Reincarnation Plan",
|
||||
"https://www.propublica.org/article/failing-charter-schools-have-a-reincarnation-plan#134669",
|
||||
)
|
||||
);
|
||||
assert_eq!(i2.uri, Some("http://tracking.feedpress.it/link/9499/6841866"));
|
||||
// Too long
|
||||
// assert_eq!(i2.description, Some(descr));
|
||||
assert_eq!(i2.length, None);
|
||||
assert_eq!(i2.guid, Some("https://www.propublica.org/article/failing-charter-schools-have-a-reincarnation-plan#134669"));
|
||||
assert_eq!(i2.published_date, Some("Tue, 19 Sep 2017 10:00:00 +0000"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_episode_lup() {
|
||||
let file = File::open("tests/feeds/LinuxUnplugged.xml").unwrap();
|
||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||
|
||||
let firstitem = channel.items().first().unwrap();
|
||||
let descr = "Audit your network with a couple of easy commands on Kali Linux. Chris decides to blow off a little steam by attacking his IoT devices, Wes has the scope on Equifax blaming open source & the Beard just saved the show. It’s a really packed episode!";
|
||||
let i = parse_episode(&firstitem, 0).unwrap();
|
||||
|
||||
assert_eq!(i.title, Some("Hacking Devices with Kali Linux | LUP 214"));
|
||||
assert_eq!(
|
||||
i.uri,
|
||||
Some(
|
||||
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0214.mp3",
|
||||
)
|
||||
);
|
||||
assert_eq!(i.description, Some(descr));
|
||||
assert_eq!(i.length, Some(46479789));
|
||||
assert_eq!(i.guid, Some("78A682B4-73E8-47B8-88C0-1BE62DD4EF9D"));
|
||||
assert_eq!(i.published_date, Some("Tue, 12 Sep 2017 22:24:42 -0700"));
|
||||
|
||||
let second = channel.items().iter().nth(1).unwrap();
|
||||
let i2 = parse_episode(&second, 0).unwrap();
|
||||
|
||||
let descr2 = "<p>The Gnome project is about to solve one of our audience's biggest Wayland’s concerns. But as the project takes on a new level of relevance, decisions for the next version of Gnome have us worried about the future.</p>
|
||||
|
||||
<p>Plus we chat with Wimpy about the Ubuntu Rally in NYC, Microsoft’s sneaky move to turn Windows 10 into the “ULTIMATE LINUX RUNTIME”, community news & more!</p>";
|
||||
assert_eq!(i2.title, Some("Gnome Does it Again | LUP 213"));
|
||||
assert_eq!(
|
||||
i2.uri,
|
||||
Some(
|
||||
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0213.mp3",
|
||||
)
|
||||
);
|
||||
assert_eq!(i2.description, Some(descr2));
|
||||
assert_eq!(i2.length, Some(36544272));
|
||||
assert_eq!(i2.guid, Some("1CE57548-B36C-4F14-832A-5D5E0A24E35B"));
|
||||
assert_eq!(i2.published_date, Some("Tue, 05 Sep 2017 20:57:27 -0700"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_episode_r4expanation() {
|
||||
let file = File::open("tests/feeds/R4Explanation.xml").unwrap();
|
||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||
|
||||
let firstitem = channel.items().iter().nth(9).unwrap();
|
||||
let descr = "This week we look at <a href=\"https://github.com/rust-lang/rfcs/pull/2094\">RFC 2094</a> \"Non-lexical lifetimes\"";
|
||||
let i = parse_episode(&firstitem, 0).unwrap();
|
||||
|
||||
assert_eq!(i.title, Some("Episode #9 - A Once in a Lifetime RFC"));
|
||||
assert_eq!(
|
||||
i.uri,
|
||||
Some(
|
||||
"http://request-for-explanation.github.io/podcast/ep9-a-once-in-a-lifetime-rfc/episode.mp3",
|
||||
)
|
||||
);
|
||||
assert_eq!(i.description, Some(descr));
|
||||
assert_eq!(i.length, Some(15077388));
|
||||
assert_eq!(i.guid, Some("https://request-for-explanation.github.io/podcast/ep9-a-once-in-a-lifetime-rfc/"));
|
||||
assert_eq!(i.published_date, Some("Mon, 28 Aug 2017 15:00:00 PDT"));
|
||||
|
||||
let second = channel.items().iter().nth(8).unwrap();
|
||||
let i2 = parse_episode(&second, 0).unwrap();
|
||||
|
||||
let descr2 = "This week we look at <a href=\"https://github.com/rust-lang/rfcs/pull/2071\">RFC 2071</a> \"Add impl Trait type alias and variable declarations\"";
|
||||
assert_eq!(i2.title, Some("Episode #8 - An Existential Crisis"));
|
||||
assert_eq!(
|
||||
i2.uri,
|
||||
Some(
|
||||
"http://request-for-explanation.github.io/podcast/ep8-an-existential-crisis/episode.mp3",
|
||||
)
|
||||
);
|
||||
assert_eq!(i2.description, Some(descr2));
|
||||
assert_eq!(i2.length, Some(13713219));
|
||||
assert_eq!(i2.guid, Some("https://request-for-explanation.github.io/podcast/ep8-an-existential-crisis/"));
|
||||
assert_eq!(i2.published_date, Some("Tue, 15 Aug 2017 17:00:00 PDT"));
|
||||
}
|
||||
}
|
||||
139
tests/feeds/R4Explanation.xml
Normal file
139
tests/feeds/R4Explanation.xml
Normal file
@ -0,0 +1,139 @@
|
||||
<?xml version="1.0"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
|
||||
<channel>
|
||||
<title>Request For Explanation</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/</link>
|
||||
<description>A weekly discussion of Rust RFCs</description>
|
||||
<image>
|
||||
<url>https://request-for-explanation.github.io/podcast/podcast.png</url>
|
||||
<title>Request For Explanation</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/</link>
|
||||
</image>
|
||||
<atom:link href="http://request-for-explanation.github.io/podcast/rss.xml" rel="self" type="application/rss+xml" />
|
||||
<googleplay:author>The Request For Explanation Podcast</googleplay:author>
|
||||
<itunes:author>The Request For Explanation Podcast</itunes:author>
|
||||
<googleplay:email>manishearth@gmail.com</googleplay:email>
|
||||
<itunes:owner>
|
||||
<itunes:name>Manish Goregaokar</itunes:name>
|
||||
<itunes:email>manishearth@gmail.com</itunes:email>
|
||||
</itunes:owner>
|
||||
<googleplay:image href="https://request-for-explanation.github.io/podcast/podcast.png" />
|
||||
<itunes:image href="https://request-for-explanation.github.io/podcast/podcast.png" />
|
||||
<language>en-us</language>
|
||||
<googleplay:category text="Technology"/>
|
||||
<itunes:category text="Technology" />
|
||||
<itunes:explicit>no</itunes:explicit>
|
||||
<item>
|
||||
<title>Episode #0 - What the Hell</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep0-what-the-hell/</link>
|
||||
<pubDate>Mon, 19 Jun 2017 19:45:01 EST</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep0-what-the-hell/</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep0-what-the-hell/episode.mp3" length="7057920" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/2005">RFC 2005</a> "Match Ergonomics Using Default Binding Modes"]]></description>
|
||||
<itunes:order>1</itunes:order>
|
||||
<itunes:duration>20:29</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #1 - Constermash</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep1-constermash/</link>
|
||||
<pubDate>Thu, 29 Jun 2017 17:30:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep1-constermash/</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep1-constermash/episode.mp3" length="28588800" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/2000">RFC 2000</a> "Const Generics"]]></description>
|
||||
<itunes:order>2</itunes:order>
|
||||
<itunes:duration>16:09</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #2 - Stealing Chickens on the Internet</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep2-stealing-chickens-on-the-internet/</link>
|
||||
<pubDate>Thu, 6 July 2017 15:30:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep2-stealing-chickens-on-the-internet</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep2-stealing-chickens-on-the-internet/episode.mp3" length="19608187" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/2052">RFC 2052</a> "Evolving Rust through Epochs"]]></description>
|
||||
<itunes:order>3</itunes:order>
|
||||
<itunes:duration>43:25</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #3 - Aaron's Favorite Topic</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep3-aarons-favorite-topic/</link>
|
||||
<pubDate>Mon, 10 July 2017 16:00:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep3-aarons-favorite-topic</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep3-aarons-favorite-topic/episode.mp3" length="19070229" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we talk about the RFC process in general -- what it is, how it works, and how it came to be.]]></description>
|
||||
<itunes:order>4</itunes:order>
|
||||
<itunes:duration>54:01</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #4 - Literally Haskell</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep4-literally-haskell/</link>
|
||||
<pubDate>Mon, 17 July 2017 17:00:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep4-literally-haskell</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep4-literally-haskell/episode.mp3" length="12973478" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/1598">RFC 1598</a> "Generic Associated Types"]]></description>
|
||||
<itunes:order>5</itunes:order>
|
||||
<itunes:duration>36:41</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #5 - Are you my main?</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep5-are-you-my-main/</link>
|
||||
<pubDate>Mon, 24 July 2017 16:00:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep5-are-you-my-main</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep5-are-you-my-main/episode.mp3" length="8232966" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/1937">RFC 1937</a> "? in main", as well as discuss some news on other RFCs.]]></description>
|
||||
<itunes:order>6</itunes:order>
|
||||
<itunes:duration>22:33</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #6 - Everything and the kitchen async</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep6-everything-and-the-kitchen-async/</link>
|
||||
<pubDate>Mon, 31 July 2017 16:00:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep6-everything-and-the-kitchen-async/</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep6-everything-and-the-kitchen-async/episode.mp3" length="9530774" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/2033">eRFC 2033</a> "Experimentally add coroutines to Rust"]]></description>
|
||||
<itunes:order>7</itunes:order>
|
||||
<itunes:duration>25:52</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #7 - Unwrapping a great RFC</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep7-unwrapping-a-great-rfc/</link>
|
||||
<pubDate>Tue, 8 Aug 2017 16:00:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep7-unwrapping-a-great-rfc/</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep7-unwrapping-a-great-rfc/episode.mp3" length="8715317" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/2091">RFC 2091</a> "Implicit caller location"]]></description>
|
||||
<itunes:order>8</itunes:order>
|
||||
<itunes:duration>24:11</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #8 - An Existential Crisis</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep8-an-existential-crisis/</link>
|
||||
<pubDate>Tue, 15 Aug 2017 17:00:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep8-an-existential-crisis/</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep8-an-existential-crisis/episode.mp3" length="13713219" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/2071">RFC 2071</a> "Add impl Trait type alias and variable declarations"]]></description>
|
||||
<itunes:order>9</itunes:order>
|
||||
<itunes:duration>38:33</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #9 - A Once in a Lifetime RFC</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep9-a-once-in-a-lifetime-rfc/</link>
|
||||
<pubDate>Mon, 28 Aug 2017 15:00:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep9-a-once-in-a-lifetime-rfc/</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep9-a-once-in-a-lifetime-rfc/episode.mp3" length="15077388" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/2094">RFC 2094</a> "Non-lexical lifetimes"]]></description>
|
||||
<itunes:order>10</itunes:order>
|
||||
<itunes:duration>42:13</itunes:duration>
|
||||
</item>
|
||||
<item>
|
||||
<title>Episode #10 - Two Paths Diverged in a Yellow Wood</title>
|
||||
<link>https://request-for-explanation.github.io/podcast/ep10-two-paths-diverged-in-a-yellow-wood/</link>
|
||||
<pubDate>Thu, 30 Aug 2017 1:30:00 PDT</pubDate>
|
||||
<guid isPermaLink="false">https://request-for-explanation.github.io/podcast/ep10-two-paths-diverged-in-a-yellow-wood/</guid>
|
||||
<enclosure url="http://request-for-explanation.github.io/podcast/ep10-two-paths-diverged-in-a-yellow-wood/episode.mp3" length="19994929" type="audio/mpeg" />
|
||||
<description><![CDATA[This week we look at <a href="https://github.com/rust-lang/rfcs/pull/2126">RFC 2126</a> "Clarify and streamline paths and visibility" (aka "The modules RFC")]]></description>
|
||||
<itunes:order>11</itunes:order>
|
||||
<itunes:duration>56:40</itunes:duration>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user