rss Channel guarantes that some fields exist and dont need to be Option<foo>.
This commit is contained in:
parent
ffda7c6fc8
commit
fe2d8c8b52
@ -22,8 +22,8 @@ CREATE TABLE `podcast` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
`title` TEXT NOT NULL,
|
||||
`uri` TEXT UNIQUE NOT NULL,
|
||||
`link` TEXT,
|
||||
`description` TEXT,
|
||||
`link` TEXT NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
`image_uri` TEXT,
|
||||
`source_id` INTEGER NOT NULL
|
||||
);
|
||||
@ -31,8 +31,8 @@ pub struct Podcast {
|
||||
id: i32,
|
||||
title: String,
|
||||
uri: String,
|
||||
link: Option<String>,
|
||||
description: Option<String>,
|
||||
link: String,
|
||||
description: String,
|
||||
image_uri: Option<String>,
|
||||
source_id: i32,
|
||||
}
|
||||
@ -77,8 +77,8 @@ pub struct NewEpisode<'a> {
|
||||
pub struct NewPodcast {
|
||||
pub title: String,
|
||||
pub uri: String,
|
||||
pub link: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub link: String,
|
||||
pub description: String,
|
||||
pub image_uri: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
@ -5,9 +5,9 @@ use errors::*;
|
||||
pub fn parse_podcast(chan: &Channel, uri: &str) -> Result<models::NewPodcast> {
|
||||
|
||||
let title = chan.title().to_owned();
|
||||
let link = chan.link().to_owned();
|
||||
|
||||
let link = Some(chan.link().to_owned());
|
||||
let description = Some(chan.description().to_owned());
|
||||
let description = chan.description().to_owned();
|
||||
|
||||
// let image_uri = match chan.image() {
|
||||
// Some(foo) => Some(foo.url().to_owned()),
|
||||
@ -86,11 +86,8 @@ mod tests {
|
||||
pd.uri,
|
||||
"https://feeds.feedburner.com/InterceptedWithJeremyScahill".to_string()
|
||||
);
|
||||
assert_eq!(
|
||||
pd.link,
|
||||
Some("https://theintercept.com/podcasts".to_string())
|
||||
);
|
||||
assert_eq!(pd.description, Some(descr.to_string()));
|
||||
assert_eq!(pd.link, "https://theintercept.com/podcasts".to_string());
|
||||
assert_eq!(pd.description, descr.to_string());
|
||||
assert_eq!(pd.image_uri, None);
|
||||
|
||||
|
||||
@ -104,11 +101,8 @@ mod tests {
|
||||
let pd = parse_podcast(&channel, uri).unwrap();
|
||||
|
||||
assert_eq!(pd.title, "LINUX Unplugged Podcast".to_string());
|
||||
assert_eq!(
|
||||
pd.link,
|
||||
Some("http://www.jupiterbroadcasting.com/".to_string())
|
||||
);
|
||||
assert_eq!(pd.description, Some(descr.to_string()));
|
||||
assert_eq!(pd.link, "http://www.jupiterbroadcasting.com/".to_string());
|
||||
assert_eq!(pd.description, descr.to_string());
|
||||
assert_eq!(
|
||||
pd.image_uri,
|
||||
Some(
|
||||
@ -132,9 +126,9 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
pd.link,
|
||||
Some("https://www.propublica.org/feeds/54Ghome".to_string())
|
||||
"https://www.propublica.org/feeds/54Ghome".to_string()
|
||||
);
|
||||
assert_eq!(pd.description, Some(descr.to_string()));
|
||||
assert_eq!(pd.description, descr.to_string());
|
||||
assert_eq!(
|
||||
pd.image_uri,
|
||||
Some(
|
||||
|
||||
@ -18,8 +18,8 @@ table! {
|
||||
id -> Integer,
|
||||
title -> Text,
|
||||
uri -> Text,
|
||||
link -> Nullable<Text>,
|
||||
description -> Nullable<Text>,
|
||||
link -> Text,
|
||||
description -> Text,
|
||||
image_uri -> Nullable<Text>,
|
||||
source_id -> Integer,
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user