From 58f6b349df55d676c260d7df86f373dcfb82b217 Mon Sep 17 00:00:00 2001 From: Gulliver Date: Mon, 31 May 2021 07:34:02 +0200 Subject: [PATCH] first test and needed dependency to diesel added (test not complete yet) --- model/sqlite3/Cargo.toml | 1 + model/sqlite3/src/lib.rs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/model/sqlite3/Cargo.toml b/model/sqlite3/Cargo.toml index bf2dc4d..fb06ea9 100644 --- a/model/sqlite3/Cargo.toml +++ b/model/sqlite3/Cargo.toml @@ -7,3 +7,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +diesel = { version = "*", features = ["sqlite"] } diff --git a/model/sqlite3/src/lib.rs b/model/sqlite3/src/lib.rs index 31e1bb2..d58d631 100644 --- a/model/sqlite3/src/lib.rs +++ b/model/sqlite3/src/lib.rs @@ -1,7 +1,29 @@ +extern crate diesel; + +pub mod db; + #[cfg(test)] mod tests { + use diesel::Connection; + use diesel::SqliteConnection; + + fn establish_connection() -> SqliteConnection { + let database_url = "test.db"; + SqliteConnection::establish(&database_url) + .unwrap_or_else(|_| panic!("Error connecting to {}", database_url)) + } + #[test] fn it_works() { assert_eq!(2 + 2, 4); } + + #[test] + fn list_users() { + use schema::dsl::*; + let connection = establish_connection(); + // db::schema:: + + // users.loa + } }