From 12ef89c13465540fe0ca2e6100b21677560e34dd Mon Sep 17 00:00:00 2001 From: heng30 <2238288979@qq.com> Date: Sun, 28 Jul 2024 23:33:17 +0800 Subject: [PATCH] [*] update config --- shell.nix | 3 +- src/db/blacklist.rs | 74 --------------------------------------------- 2 files changed, 2 insertions(+), 75 deletions(-) diff --git a/shell.nix b/shell.nix index 11fb00b..e7a3fc6 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,5 @@ { pkgs ? import { } }: pkgs.mkShell { - buildInputs = with pkgs; [libGL.dev ]; + buildInputs = with pkgs; [ libGL.dev openssl qt5.full xorg.libxcb ]; + nativeBuildInputs = with pkgs; [ pkg-config python3 ]; } diff --git a/src/db/blacklist.rs b/src/db/blacklist.rs index dfe16b4..6d40527 100644 --- a/src/db/blacklist.rs +++ b/src/db/blacklist.rs @@ -44,77 +44,3 @@ pub async fn is_exist(md5: &str) -> Result<()> { select(md5).await?; Ok(()) } - -#[cfg(test)] -mod tests { - use super::*; - use crate::db; - use std::sync::Mutex; - - static MTX: Mutex<()> = Mutex::new(()); - const DB_PATH: &str = "/tmp/rssbox-blacklist-test.db"; - - #[tokio::test] - async fn test_table_new() -> Result<()> { - let _mtx = MTX.lock().unwrap(); - db::init(DB_PATH).await; - new().await - } - - #[tokio::test] - async fn test_delete_all() -> Result<()> { - let _mtx = MTX.lock().unwrap(); - db::init(DB_PATH).await; - new().await?; - delete_all().await - } - - #[tokio::test] - async fn test_insert() -> Result<()> { - let _mtx = MTX.lock().unwrap(); - db::init(DB_PATH).await; - new().await?; - delete_all().await?; - insert("md5-1").await?; - insert("md5-2").await - } - - #[tokio::test] - async fn test_select_one() -> Result<()> { - let _mtx = MTX.lock().unwrap(); - db::init(DB_PATH).await; - new().await?; - delete_all().await?; - assert!(select("md5-1").await.is_err()); - - insert("md5-1").await?; - assert_eq!(select("md5-1").await?, "md5-1"); - Ok(()) - } - - #[tokio::test] - async fn test_is_exist() -> Result<()> { - let _mtx = MTX.lock().unwrap(); - db::init(DB_PATH).await; - new().await?; - delete_all().await?; - insert("md5-1").await?; - - assert!(is_exist("md5-0").await.is_err()); - assert!(is_exist("md5-1").await.is_ok()); - Ok(()) - } - - #[tokio::test] - async fn test_row_count() -> Result<()> { - let _mtx = MTX.lock().unwrap(); - db::init(DB_PATH).await; - new().await?; - delete_all().await?; - assert_eq!(row_count().await.unwrap(), 0); - - insert("md5-1").await?; - assert_eq!(row_count().await.unwrap(), 1); - Ok(()) - } -}