hammond-data::parser: Refactor Podcast tests.

This commit is contained in:
Jordan Petridis 2017-12-25 23:29:42 +02:00
parent eee491f17c
commit fde4bedce6
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 48 additions and 38 deletions

View File

@ -22,7 +22,7 @@ trait Update {
#[derive(Insertable)] #[derive(Insertable)]
#[table_name = "source"] #[table_name = "source"]
#[derive(Debug, Clone, Default, Builder)] #[derive(Debug, Clone, Default, Builder, PartialEq)]
#[builder(default)] #[builder(default)]
#[builder(derive(Debug))] #[builder(derive(Debug))]
#[builder(setter(into))] #[builder(setter(into))]
@ -68,7 +68,7 @@ impl NewSource {
#[derive(Insertable, AsChangeset)] #[derive(Insertable, AsChangeset)]
#[table_name = "podcast"] #[table_name = "podcast"]
#[derive(Debug, Clone, Default, Builder)] #[derive(Debug, Clone, Default, Builder, PartialEq)]
#[builder(default)] #[builder(default)]
#[builder(derive(Debug))] #[builder(derive(Debug))]
#[builder(setter(into))] #[builder(setter(into))]
@ -152,7 +152,7 @@ impl NewPodcast {
#[derive(Insertable, AsChangeset)] #[derive(Insertable, AsChangeset)]
#[table_name = "episode"] #[table_name = "episode"]
#[derive(Debug, Clone, Default, Builder)] #[derive(Debug, Clone, Default, Builder, PartialEq)]
#[builder(default)] #[builder(default)]
#[builder(derive(Debug))] #[builder(derive(Debug))]
#[builder(setter(into))] #[builder(setter(into))]

View File

@ -128,19 +128,21 @@ mod tests {
the crucial issues of our time: national security, civil liberties, foreign \ the crucial issues of our time: national security, civil liberties, foreign \
policy, and criminal justice. Plus interviews with artists, thinkers, and \ policy, and criminal justice. Plus interviews with artists, thinkers, and \
newsmakers who challenge our preconceptions about the world we live in."; newsmakers who challenge our preconceptions about the world we live in.";
let pd = new_podcast(&channel, 0);
assert_eq!(pd.title(), "Intercepted with Jeremy Scahill"); let pd = new_podcast(&channel, 0);
assert_eq!(pd.link(), "https://theintercept.com/podcasts"); let expected = NewPodcastBuilder::default()
assert_eq!(pd.description(), descr); .title("Intercepted with Jeremy Scahill")
assert_eq!( .link("https://theintercept.com/podcasts")
pd.image_uri(), .description(descr)
Some( .image_uri(Some(String::from(
"http://static.megaphone.fm/podcasts/d5735a50-d904-11e6-8532-73c7de466ea6/image/\ "http://static.megaphone.fm/podcasts/d5735a50-d904-11e6-8532-73c7de466ea6/image/\
uploads_2F1484252190700-qhn5krasklbce3dh-a797539282700ea0298a3a26f7e49b0b_\ uploads_2F1484252190700-qhn5krasklbce3dh-a797539282700ea0298a3a26f7e49b0b_\
2FIntercepted_COVER%2B_281_29.png" 2FIntercepted_COVER%2B_281_29.png")
) ))
); .build()
.unwrap();
assert_eq!(pd, expected);
} }
#[test] #[test]
@ -153,13 +155,17 @@ mod tests {
interest."; interest.";
let pd = new_podcast(&channel, 0); let pd = new_podcast(&channel, 0);
assert_eq!(pd.title(), "The Breakthrough"); let expected = NewPodcastBuilder::default()
assert_eq!(pd.link(), "http://www.propublica.org/podcast"); .title("The Breakthrough")
assert_eq!(pd.description(), descr); .link("http://www.propublica.org/podcast")
assert_eq!( .description(descr)
pd.image_uri(), .image_uri(Some(String::from(
Some("http://www.propublica.org/images/podcast_logo_2.png") "http://www.propublica.org/images/podcast_logo_2.png",
); )))
.build()
.unwrap();
assert_eq!(pd, expected);
} }
#[test] #[test]
@ -172,13 +178,17 @@ mod tests {
Linux."; Linux.";
let pd = new_podcast(&channel, 0); let pd = new_podcast(&channel, 0);
assert_eq!(pd.title(), "LINUX Unplugged Podcast"); let expected = NewPodcastBuilder::default()
assert_eq!(pd.link(), "http://www.jupiterbroadcasting.com/"); .title("LINUX Unplugged Podcast")
assert_eq!(pd.description(), descr); .link("http://www.jupiterbroadcasting.com/")
assert_eq!( .description(descr)
pd.image_uri(), .image_uri(Some(String::from(
Some("http://www.jupiterbroadcasting.com/images/LASUN-Badge1400.jpg") "http://www.jupiterbroadcasting.com/images/LASUN-Badge1400.jpg",
); )))
.build()
.unwrap();
assert_eq!(pd, expected);
} }
#[test] #[test]
@ -187,18 +197,18 @@ mod tests {
let channel = Channel::read_from(BufReader::new(file)).unwrap(); let channel = Channel::read_from(BufReader::new(file)).unwrap();
let pd = new_podcast(&channel, 0); let pd = new_podcast(&channel, 0);
let descr = "A weekly discussion of Rust RFCs";
assert_eq!(pd.title(), "Request For Explanation"); let expected = NewPodcastBuilder::default()
assert_eq!( .title("Request For Explanation")
pd.link(), .link("https://request-for-explanation.github.io/podcast/")
"https://request-for-explanation.github.io/podcast/" .description("A weekly discussion of Rust RFCs")
); .image_uri(Some(String::from(
assert_eq!(pd.description(), descr); "https://request-for-explanation.github.io/podcast/podcast.png",
assert_eq!( )))
pd.image_uri(), .build()
Some("https://request-for-explanation.github.io/podcast/podcast.png") .unwrap();
);
assert_eq!(pd, expected);
} }
#[test] #[test]