db, add channel and feed; user.get_feeds
Adds the primary functionality for channel and feed Also adds a function to user to get the feeds associated with a user.
This commit is contained in:
parent
ce95a54227
commit
09b26c1b39
7 changed files with 1400 additions and 17 deletions
|
|
@ -3,15 +3,28 @@
|
|||
use crate::{
|
||||
Adapter,
|
||||
AdapterBuilder,
|
||||
AdapterPool,
|
||||
db::{
|
||||
Channel,
|
||||
Feed,
|
||||
User,
|
||||
}
|
||||
};
|
||||
use reqwest::Url;
|
||||
use chrono::{
|
||||
Utc,
|
||||
TimeZone,
|
||||
DateTime
|
||||
};
|
||||
|
||||
pub const FEED1: &str = "https://example.com/feed";
|
||||
pub const FEED2: &str = "https://example2.com/feed";
|
||||
pub const USERNAME: &str = "Alice";
|
||||
pub const USERNAME2: &str = "Bob";
|
||||
pub const FEED_TITLE: &str = "My Feed!";
|
||||
pub const FEED_TITLE2: &str = "My Second Feed!";
|
||||
pub const CHANNEL_TITLE: &str = "My Channel!";
|
||||
pub const CHANNEL_DESC: &str = "My Channel's description";
|
||||
|
||||
pub fn get_datetime() -> DateTime<Utc> {
|
||||
Utc.with_ymd_and_hms(2020,1,1,0,0,0).unwrap()
|
||||
|
|
@ -22,3 +35,13 @@ pub async fn setup_adapter() -> Adapter {
|
|||
.database_url("sqlite::memory:")
|
||||
.create().await.unwrap()
|
||||
}
|
||||
|
||||
pub async fn setup_channel(pool: &AdapterPool) -> Channel {
|
||||
let url = Url::parse(FEED1).unwrap();
|
||||
Channel::get_or_create(pool, url).await.unwrap()
|
||||
}
|
||||
|
||||
pub async fn setup_feed(pool: &AdapterPool) -> Feed {
|
||||
let user = User::create(pool, USERNAME).await.unwrap();
|
||||
Feed::create(pool, user.key(), FEED_TITLE).await.unwrap()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue