first test and needed dependency to diesel added (test not complete yet)

This commit is contained in:
gulliver 2021-05-31 07:34:02 +02:00
parent 1645ed984d
commit 58f6b349df
2 changed files with 23 additions and 0 deletions

View File

@ -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"] }

View File

@ -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
}
}