Skip to content

Commit

Permalink
[*] update config
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed Jul 28, 2024
1 parent cb21035 commit 12ef89c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 75 deletions.
3 changes: 2 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
buildInputs = with pkgs; [libGL.dev ];
buildInputs = with pkgs; [ libGL.dev openssl qt5.full xorg.libxcb ];
nativeBuildInputs = with pkgs; [ pkg-config python3 ];
}
74 changes: 0 additions & 74 deletions src/db/blacklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}

0 comments on commit 12ef89c

Please sign in to comment.