add tests

This commit is contained in:
Namekuji 2023-05-27 06:28:27 -04:00
parent 4012d38f7f
commit 6bbfe1a6b4
No known key found for this signature in database
GPG Key ID: B541BD6E646CABC7
2 changed files with 4 additions and 9 deletions

View File

@ -19,17 +19,10 @@ pub fn get_database() -> Result<&'static DatabaseConnection, Error> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::get_database; use super::get_database;
use crate::{error::Error, init_database}; use crate::error::Error;
#[test] #[test]
fn unit_lib_error_uninitialized() { fn unit_lib_error_uninitialized() {
assert_eq!(get_database().unwrap_err(), Error::Uninitialized); assert_eq!(get_database().unwrap_err(), Error::Uninitialized);
} }
#[tokio::test]
async fn unit_lib_connect_in_memory_sqlite() -> Result<(), Error> {
init_database("sqlite::memory:").await?;
get_database()?;
Ok(())
}
} }

View File

@ -39,6 +39,8 @@
"prepublishOnly": "napi prepublish -t npm", "prepublishOnly": "napi prepublish -t npm",
"test": "ava", "test": "ava",
"universal": "napi universal", "universal": "napi universal",
"version": "napi version" "version": "napi version",
"cargo:unit": "cargo test --workspace unit",
"cargo:integration": "cargo test --workspace inte -- --test-threads=1"
} }
} }