rss Channel guarantes that some fields exist and dont need to be Option<foo>.

This commit is contained in:
Jordan Petridis 2017-09-19 08:33:14 +03:00
parent ffda7c6fc8
commit fe2d8c8b52
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
4 changed files with 16 additions and 22 deletions

View File

@ -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
);

View File

@ -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>,
}

View File

@ -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(

View File

@ -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,
}