i5-add-tests (part 2) #7

Merged
kemitix merged 10 commits from i5-add-tests into main 2023-07-28 18:35:41 +01:00
4 changed files with 8 additions and 9 deletions
Showing only changes of commit d7729cc2a3 - Show all commits

View file

@ -31,7 +31,7 @@ mod tests {
//given //given
let fetch_get = &(get as FetchGet); let fetch_get = &(get as FetchGet);
//when //when
let result = find("site", "@channel", &fetch_get)?; let result = find("site", "@channel", fetch_get)?;
//then //then
assert_eq!(result, "the-rss-url"); assert_eq!(result, "the-rss-url");
Ok(()) Ok(())
@ -42,7 +42,7 @@ mod tests {
//given //given
let fetch_get = &(get as FetchGet); let fetch_get = &(get as FetchGet);
//when //when
let result = find("site", "invalid-channel-name", &fetch_get); let result = find("site", "invalid-channel-name", fetch_get);
//then //then
assert!(result.is_err()); assert!(result.is_err());
Ok(()) Ok(())

View file

@ -1,8 +1,8 @@
use atom_syndication::Feed;
use crate::prelude::*; use crate::prelude::*;
pub fn get(url: &str) -> Result<Feed> { use atom_syndication::Feed;
pub fn reqwest_blocking_get(url: &str) -> Result<Feed> {
let content = reqwest::blocking::get(url)?.bytes()?; let content = reqwest::blocking::get(url)?.bytes()?;
let channel = Feed::read_from(&content[..])?; let channel = Feed::read_from(&content[..])?;
Ok(channel) Ok(channel)

View file

@ -5,10 +5,9 @@ use crate::fetch::FetchGet;
mod find; mod find;
mod get; mod get;
use atom_syndication::Feed;
pub use find::find; pub use find::find;
pub use get::get; pub use get::reqwest_blocking_get;
type Feed = atom_syndication::Feed;
pub struct FeedEnv { pub struct FeedEnv {
pub find: FeedFind, pub find: FeedFind,

View file

@ -15,7 +15,7 @@ fn main() -> Result<()> {
podal::Env { podal::Env {
feed: FeedEnv { feed: FeedEnv {
find: podal::feed::find, find: podal::feed::find,
get: podal::feed::get, get: podal::feed::reqwest_blocking_get,
}, },
history: HistoryEnv { history: HistoryEnv {