#![cfg(test)] 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.with_ymd_and_hms(2020,1,1,0,0,0).unwrap() } pub async fn setup_adapter() -> Adapter { AdapterBuilder::new() .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() }