passing all tests ready for wrapper implementation
This commit is contained in:
parent
9b035f07a2
commit
5803fc4c53
@ -1,7 +1,38 @@
|
|||||||
|
#[macro_use]
|
||||||
|
extern crate diesel;
|
||||||
|
extern crate dotenv;
|
||||||
|
|
||||||
|
pub mod schema;
|
||||||
|
pub mod models;
|
||||||
|
|
||||||
|
use diesel::prelude::*;
|
||||||
|
use dotenv::dotenv;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
|
||||||
|
struct DB {
|
||||||
|
conn: MysqlConnection,
|
||||||
|
url: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
extern crate diesel;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
use super::models::*;
|
||||||
|
use super::diesel::prelude::*;
|
||||||
|
use super::dotenv::dotenv;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn test_conn() {
|
||||||
assert_eq!(2 + 2, 4);
|
let url = env::var("DATABASE_URL")
|
||||||
|
.expect("DATABASE_URL not set!");
|
||||||
|
let conn = MysqlConnection::establish(&url)
|
||||||
|
.expect(&format!("Error connecting to {}", url));
|
||||||
|
|
||||||
|
let db = DB{conn, url};
|
||||||
|
println!("{}", db.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
server/src/db_io/src/models.rs
Normal file
15
server/src/db_io/src/models.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#[derive(Queryable)]
|
||||||
|
pub struct User {
|
||||||
|
pub id: u64,
|
||||||
|
pub strid: String,
|
||||||
|
display: String,
|
||||||
|
native: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Queryable)]
|
||||||
|
pub struct channels {
|
||||||
|
pub id: i64,
|
||||||
|
pub name: String,
|
||||||
|
pub ctype: i64,
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user