From c75bea391396cc138ac908d6b8859394b8eceaa3 Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Fri, 24 Mar 2023 08:00:48 -0400 Subject: [PATCH] Setup initial db session. --- src/morethantext/mod.rs | 27 ++++++++++++++++++++++----- src/morethantext/session.rs | 17 +++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/morethantext/mod.rs b/src/morethantext/mod.rs index faa529f..6f03b11 100644 --- a/src/morethantext/mod.rs +++ b/src/morethantext/mod.rs @@ -1,15 +1,14 @@ mod database; mod entry; mod error; +mod session; mod store; -use async_std::{ - fs::{write}, - path::PathBuf, -}; +use async_std::path::PathBuf; use database::Database; use entry::Entry; use error::{DBError, ErrorCode}; +use session::Session; use std::{slice, str}; use store::Store; @@ -135,6 +134,10 @@ impl MoreThanText { } } } + + fn new_session(&self) -> Session { + Session::new() + } } #[cfg(test)] @@ -297,8 +300,9 @@ mod datatype_file { } #[cfg(test)] -mod cache { +mod create { use super::*; + use async_std::fs::write; use std::error::Error; use tempfile::tempdir; @@ -363,3 +367,16 @@ mod cache { } } } + +#[cfg(test)] +mod sessions { + use super::*; + use tempfile::tempdir; + + #[async_std::test] + async fn create_session() { + let dir = tempdir().unwrap(); + let mtt = MoreThanText::new(dir.path().to_str().unwrap()).await.unwrap(); + mtt.new_session(); + } +} diff --git a/src/morethantext/session.rs b/src/morethantext/session.rs index e69de29..beb9602 100644 --- a/src/morethantext/session.rs +++ b/src/morethantext/session.rs @@ -0,0 +1,17 @@ +pub struct Session; + +impl Session { + pub fn new() -> Self { + Self {} + } +} + +#[cfg(test)] +mod session { + use super::*; + + #[test] + fn create() { + Session::new(); + } +}