NewEpisode: Clean up tests a bit.
This commit is contained in:
parent
d231cc165f
commit
2d6f34fa4d
@ -275,15 +275,9 @@ mod tests {
|
|||||||
// TODO: Add tests for other feeds too.
|
// TODO: Add tests for other feeds too.
|
||||||
// Especially if you find an *intresting* generated feed.
|
// Especially if you find an *intresting* generated feed.
|
||||||
|
|
||||||
#[test]
|
lazy_static! {
|
||||||
fn test_new_episode_minimal_intercepted() {
|
static ref EXPECTED_MINIMAL_INTERCEPTED_1: NewEpisodeMinimal = {
|
||||||
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
|
NewEpisodeMinimalBuilder::default()
|
||||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
|
||||||
|
|
||||||
let episode = channel.items().iter().nth(14).unwrap();
|
|
||||||
|
|
||||||
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
|
|
||||||
let expected = NewEpisodeMinimalBuilder::default()
|
|
||||||
.title("The Super Bowl of Racism")
|
.title("The Super Bowl of Racism")
|
||||||
.uri(Some(String::from(
|
.uri(Some(String::from(
|
||||||
"http://traffic.megaphone.fm/PPY6458293736.mp3",
|
"http://traffic.megaphone.fm/PPY6458293736.mp3",
|
||||||
@ -293,14 +287,11 @@ mod tests {
|
|||||||
.duration(Some(4171))
|
.duration(Some(4171))
|
||||||
.podcast_id(42)
|
.podcast_id(42)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(ep, expected);
|
static ref EXPECTED_MINIMAL_INTERCEPTED_2: NewEpisodeMinimal = {
|
||||||
|
NewEpisodeMinimalBuilder::default()
|
||||||
let episode = channel.items().iter().nth(15).unwrap();
|
|
||||||
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
|
|
||||||
|
|
||||||
let expected = NewEpisodeMinimalBuilder::default()
|
|
||||||
.title("Atlas Golfed — U.S.-Backed Think Tanks Target Latin America")
|
.title("Atlas Golfed — U.S.-Backed Think Tanks Target Latin America")
|
||||||
.uri(Some(String::from(
|
.uri(Some(String::from(
|
||||||
"http://traffic.megaphone.fm/FL5331443769.mp3",
|
"http://traffic.megaphone.fm/FL5331443769.mp3",
|
||||||
@ -310,25 +301,17 @@ mod tests {
|
|||||||
.duration(Some(4415))
|
.duration(Some(4415))
|
||||||
.podcast_id(42)
|
.podcast_id(42)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(ep, expected);
|
static ref EXPECTED_INTERCEPTED_1: NewEpisode = {
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_new_episode_intercepted() {
|
|
||||||
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
|
|
||||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
|
||||||
|
|
||||||
let episode = channel.items().iter().nth(14).unwrap();
|
|
||||||
let descr = "NSA whistleblower Edward Snowden discusses the massive Equifax data breach \
|
let descr = "NSA whistleblower Edward Snowden discusses the massive Equifax data breach \
|
||||||
and allegations of Russian interference in the US election. Commentator \
|
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 \
|
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 \
|
campaign to bring violent neo-Nazis to justice. Rapper Open Mike Eagle \
|
||||||
performs.";
|
performs.";
|
||||||
|
|
||||||
let ep = NewEpisode::new(&episode, 42).unwrap();
|
NewEpisodeBuilder::default()
|
||||||
let expected = NewEpisodeBuilder::default()
|
|
||||||
.title("The Super Bowl of Racism")
|
.title("The Super Bowl of Racism")
|
||||||
.uri(Some(String::from(
|
.uri(Some(String::from(
|
||||||
"http://traffic.megaphone.fm/PPY6458293736.mp3",
|
"http://traffic.megaphone.fm/PPY6458293736.mp3",
|
||||||
@ -340,13 +323,10 @@ mod tests {
|
|||||||
.duration(Some(4171))
|
.duration(Some(4171))
|
||||||
.podcast_id(42)
|
.podcast_id(42)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
assert_eq!(ep, expected);
|
|
||||||
|
|
||||||
let episode = channel.items().iter().nth(15).unwrap();
|
|
||||||
let ep = NewEpisode::new(&episode, 42).unwrap();
|
|
||||||
|
|
||||||
|
static ref EXPECTED_INTERCEPTED_2: NewEpisode = {
|
||||||
let descr = "This week on Intercepted: Jeremy gives an update on the aftermath of \
|
let descr = "This week on Intercepted: Jeremy gives an update on the aftermath of \
|
||||||
Blackwater’s 2007 massacre of Iraqi civilians. Intercept reporter Lee Fang \
|
Blackwater’s 2007 massacre of Iraqi civilians. Intercept reporter Lee Fang \
|
||||||
lays out how a network of libertarian think tanks called the Atlas Network \
|
lays out how a network of libertarian think tanks called the Atlas Network \
|
||||||
@ -356,7 +336,7 @@ mod tests {
|
|||||||
Caracas-based band, La Pequeña Revancha, talk about her music and hopes for \
|
Caracas-based band, La Pequeña Revancha, talk about her music and hopes for \
|
||||||
Venezuela.";
|
Venezuela.";
|
||||||
|
|
||||||
let expected = NewEpisodeBuilder::default()
|
NewEpisodeBuilder::default()
|
||||||
.title("Atlas Golfed — U.S.-Backed Think Tanks Target Latin America")
|
.title("Atlas Golfed — U.S.-Backed Think Tanks Target Latin America")
|
||||||
.uri(Some(String::from(
|
.uri(Some(String::from(
|
||||||
"http://traffic.megaphone.fm/FL5331443769.mp3",
|
"http://traffic.megaphone.fm/FL5331443769.mp3",
|
||||||
@ -368,20 +348,11 @@ mod tests {
|
|||||||
.duration(Some(4415))
|
.duration(Some(4415))
|
||||||
.podcast_id(42)
|
.podcast_id(42)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(ep, expected);
|
static ref EXPECTED_MINIMAL_LUP_1: NewEpisodeMinimal = {
|
||||||
}
|
NewEpisodeMinimalBuilder::default()
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_new_episode_minimal_lup() {
|
|
||||||
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml").unwrap();
|
|
||||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
|
||||||
|
|
||||||
let episode = channel.items().iter().nth(18).unwrap();
|
|
||||||
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
|
|
||||||
|
|
||||||
let expected = NewEpisodeMinimalBuilder::default()
|
|
||||||
.title("Hacking Devices with Kali Linux | LUP 214")
|
.title("Hacking Devices with Kali Linux | LUP 214")
|
||||||
.uri(Some(String::from(
|
.uri(Some(String::from(
|
||||||
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0214.mp3",
|
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0214.mp3",
|
||||||
@ -391,14 +362,11 @@ mod tests {
|
|||||||
.duration(Some(5733))
|
.duration(Some(5733))
|
||||||
.podcast_id(42)
|
.podcast_id(42)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(ep, expected);
|
static ref EXPECTED_MINIMAL_LUP_2: NewEpisodeMinimal = {
|
||||||
|
NewEpisodeMinimalBuilder::default()
|
||||||
let episode = channel.items().iter().nth(19).unwrap();
|
|
||||||
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
|
|
||||||
|
|
||||||
let expected = NewEpisodeMinimalBuilder::default()
|
|
||||||
.title("Gnome Does it Again | LUP 213")
|
.title("Gnome Does it Again | LUP 213")
|
||||||
.uri(Some(String::from(
|
.uri(Some(String::from(
|
||||||
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0213.mp3",
|
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0213.mp3",
|
||||||
@ -408,24 +376,16 @@ mod tests {
|
|||||||
.duration(Some(4491))
|
.duration(Some(4491))
|
||||||
.podcast_id(42)
|
.podcast_id(42)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(ep, expected);
|
static ref EXPECTED_LUP_1: NewEpisode = {
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_new_episode_lup() {
|
|
||||||
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml").unwrap();
|
|
||||||
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
|
||||||
|
|
||||||
let episode = channel.items().iter().nth(18).unwrap();
|
|
||||||
let descr = "Audit your network with a couple of easy commands on Kali Linux. Chris \
|
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 \
|
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. \
|
scope on Equifax blaming open source & the Beard just saved the show. \
|
||||||
It’s a really packed episode!";
|
It’s a really packed episode!";
|
||||||
let ep = NewEpisode::new(&episode, 42).unwrap();
|
|
||||||
|
|
||||||
let expected = NewEpisodeBuilder::default()
|
NewEpisodeBuilder::default()
|
||||||
.title("Hacking Devices with Kali Linux | LUP 214")
|
.title("Hacking Devices with Kali Linux | LUP 214")
|
||||||
.uri(Some(String::from(
|
.uri(Some(String::from(
|
||||||
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0214.mp3",
|
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0214.mp3",
|
||||||
@ -437,21 +397,17 @@ mod tests {
|
|||||||
.duration(Some(5733))
|
.duration(Some(5733))
|
||||||
.podcast_id(42)
|
.podcast_id(42)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
assert_eq!(ep, expected);
|
static ref EXPECTED_LUP_2: NewEpisode = {
|
||||||
|
let descr = "The Gnome project is about to solve one of our audience's biggest Wayland’s \
|
||||||
let episode = channel.items().iter().nth(19).unwrap();
|
|
||||||
let ep = NewEpisode::new(&episode, 42).unwrap();
|
|
||||||
|
|
||||||
let descr =
|
|
||||||
"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 \
|
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.\nPlus we chat with Wimpy \
|
next version of Gnome have us worried about the future.\nPlus we chat with Wimpy \
|
||||||
about the Ubuntu Rally in NYC, Microsoft’s sneaky move to turn Windows 10 into the \
|
about the Ubuntu Rally in NYC, Microsoft’s sneaky move to turn Windows 10 into the \
|
||||||
“ULTIMATE LINUX RUNTIME”, community news & more!";
|
“ULTIMATE LINUX RUNTIME”, community news & more!";
|
||||||
|
|
||||||
let expected = NewEpisodeBuilder::default()
|
NewEpisodeBuilder::default()
|
||||||
.title("Gnome Does it Again | LUP 213")
|
.title("Gnome Does it Again | LUP 213")
|
||||||
.uri(Some(String::from(
|
.uri(Some(String::from(
|
||||||
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0213.mp3",
|
"http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/jnite/lup-0213.mp3",
|
||||||
@ -463,8 +419,64 @@ mod tests {
|
|||||||
.duration(Some(4491))
|
.duration(Some(4491))
|
||||||
.podcast_id(42)
|
.podcast_id(42)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
assert_eq!(ep, expected);
|
#[test]
|
||||||
|
fn test_new_episode_minimal_intercepted() {
|
||||||
|
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
|
||||||
|
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||||
|
|
||||||
|
let episode = channel.items().iter().nth(14).unwrap();
|
||||||
|
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
|
||||||
|
assert_eq!(ep, *EXPECTED_MINIMAL_INTERCEPTED_1);
|
||||||
|
|
||||||
|
let episode = channel.items().iter().nth(15).unwrap();
|
||||||
|
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
|
||||||
|
assert_eq!(ep, *EXPECTED_MINIMAL_INTERCEPTED_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_new_episode_intercepted() {
|
||||||
|
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
|
||||||
|
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||||
|
|
||||||
|
let episode = channel.items().iter().nth(14).unwrap();
|
||||||
|
let ep = NewEpisode::new(&episode, 42).unwrap();
|
||||||
|
assert_eq!(ep, *EXPECTED_INTERCEPTED_1);
|
||||||
|
|
||||||
|
let episode = channel.items().iter().nth(15).unwrap();
|
||||||
|
let ep = NewEpisode::new(&episode, 42).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(ep, *EXPECTED_INTERCEPTED_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_new_episode_minimal_lup() {
|
||||||
|
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml").unwrap();
|
||||||
|
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||||
|
|
||||||
|
let episode = channel.items().iter().nth(18).unwrap();
|
||||||
|
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
|
||||||
|
assert_eq!(ep, *EXPECTED_MINIMAL_LUP_1);
|
||||||
|
|
||||||
|
let episode = channel.items().iter().nth(19).unwrap();
|
||||||
|
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
|
||||||
|
assert_eq!(ep, *EXPECTED_MINIMAL_LUP_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_new_episode_lup() {
|
||||||
|
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml").unwrap();
|
||||||
|
let channel = Channel::read_from(BufReader::new(file)).unwrap();
|
||||||
|
|
||||||
|
let episode = channel.items().iter().nth(18).unwrap();
|
||||||
|
let ep = NewEpisode::new(&episode, 42).unwrap();
|
||||||
|
assert_eq!(ep, *EXPECTED_LUP_1);
|
||||||
|
|
||||||
|
let episode = channel.items().iter().nth(19).unwrap();
|
||||||
|
let ep = NewEpisode::new(&episode, 42).unwrap();
|
||||||
|
assert_eq!(ep, *EXPECTED_LUP_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user