44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
|
|
#![cfg(test)]
|
||
|
|
|
||
|
|
use crate::{
|
||
|
|
Adapter,
|
||
|
|
AdapterBuilder,
|
||
|
|
AdapterPool,
|
||
|
|
db::{
|
||
|
|
Channel,
|
||
|
|
Feed,
|
||
|
|
User,
|
||
|
|
}
|
||
|
|
};
|
||
|
|
use reqwest::Url;
|
||
|
|
|
||
|
|
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 const ITEM_GUID: &str = "item-guid";
|
||
|
|
pub const ITEM_GUID2: &str = "item-guid2";
|
||
|
|
pub const ITEM_TITLE: &str = "My Item!";
|
||
|
|
pub const ITEM_DESC: &str = "My Item's description";
|
||
|
|
pub const ITEM_CONT: &str = "The content of my Item";
|
||
|
|
|
||
|
|
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.id(), FEED_TITLE).await.unwrap()
|
||
|
|
}
|