Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion optd-persistent/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion optd-persistent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ trait-variant = "0.1.2"
async-trait = "0.1.43"
async-stream = "0.3.1"
strum = "0.26.1"
lazy_static = "1"
27 changes: 13 additions & 14 deletions optd-persistent/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(dead_code)]

use std::sync::atomic::AtomicUsize;
use std::{cell::LazyCell, sync::atomic::AtomicUsize};

use sea_orm::*;
use sea_orm_migration::prelude::*;
Expand All @@ -17,19 +17,18 @@ pub const DATABASE_FILENAME: &str = "sqlite.db";
pub const DATABASE_URL: &str = "sqlite:./sqlite.db?mode=rwc";

pub const TEST_DATABASE_FILENAME: &str = "init.db";
lazy_static::lazy_static! {
pub static ref TEST_DATABASE_FILE: String = {
std::env::current_dir().unwrap()
.join("src")
.join("db")
.join(TEST_DATABASE_FILENAME)
.to_str()
.unwrap()
.to_owned()
};
pub static ref TEST_DATABASE_URL: String =
get_sqlite_url(TEST_DATABASE_FILE.as_str());
}
pub const TEST_DATABASE_FILE: LazyCell<String> = LazyCell::new(|| {
std::env::current_dir()
.unwrap()
.join("src")
.join("db")
.join(TEST_DATABASE_FILENAME)
.to_str()
.unwrap()
.to_owned()
});
pub const TEST_DATABASE_URL: LazyCell<String> =
LazyCell::new(|| get_sqlite_url(TEST_DATABASE_FILE.as_str()));

fn get_sqlite_url(file: &str) -> String {
format!("sqlite:{}?mode=rwc", file)
Expand Down
Loading