diff options
Diffstat (limited to 'src/database/mod.rs')
-rw-r--r-- | src/database/mod.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/database/mod.rs b/src/database/mod.rs index 943a1ad..98c2cae 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -160,6 +160,12 @@ pub trait Storage: Clone + Send + Sync { /// Deletes a post from the database irreversibly. 'nuff said. Must be idempotent. async fn delete_post<'a>(&self, url: &'a str) -> Result<()>; + + /// Gets a setting from the setting store and passes the result. + async fn get_setting<'a>(&self, setting: &'a str, user: &'a str) -> Result<String>; + + /// Commits a setting to the setting store. + async fn set_setting<'a>(&self, setting: &'a str, user: &'a str, value: &'a str) -> Result<()>; } #[cfg(test)] @@ -220,6 +226,11 @@ mod tests { assert_eq!(chans[0], MicropubChannel { uid: "https://fireburn.ru/feeds/main".to_string(), name: "Main Page".to_string() }); } + async fn test_backend_settings<Backend: Storage>(backend: Backend) { + backend.set_setting("site_name", "https://fireburn.ru/", "Vika's Hideout").await.unwrap(); + assert_eq!(backend.get_setting("site_name", "https://fireburn.ru/").await.unwrap(), "Vika's Hideout"); + } + #[async_std::test] async fn test_redis_storage_basic_operations() { let redis_instance = get_redis_instance().await; @@ -232,4 +243,11 @@ mod tests { let backend = super::RedisStorage::new(redis_instance.uri().to_string()).await.unwrap(); test_backend_get_channel_list(backend).await; } + + #[async_std::test] + async fn test_redis_settings() { + let redis_instance = get_redis_instance().await; + let backend = super::RedisStorage::new(redis_instance.uri().to_string()).await.unwrap(); + test_backend_settings(backend).await; + } } |