notesmachine/server/nm-store/src/lib.rs

38 lines
917 B
Rust
Raw Normal View History

mod errors;
mod store;
mod structs;
pub use crate::store::NoteStore;
pub use crate::errors::NoteStoreError;
#[cfg(test)]
mod tests {
use super::*;
use tokio;
async fn fresh_inmemory_database() -> NoteStore {
let storagepool = NoteStore::new("sqlite://:memory:").await;
assert!(storagepool.is_ok());
let storagepool = storagepool.unwrap();
assert!(storagepool.reset_database().await.is_ok());
storagepool
}
#[tokio::test(threaded_scheduler)]
async fn fetching_unfound_page_works() {
let storagepool = fresh_inmemory_database().await;
let unfoundpage = storagepool.fetch_page("nonexistent-page").await;
assert!(unfoundpage.is_err());
}
#[tokio::test(threaded_scheduler)]
async fn fetching_unfound_note_works() {
let storagepool = fresh_inmemory_database().await;
let unfoundnote = storagepool.fetch_note("nonexistent-note").await;
assert!(unfoundnote.is_err());
}
}