forked from Ruderverein-Donau-Linz/rowt
remove unused users
This commit is contained in:
parent
153d7f84e1
commit
7a2639bbb1
@ -13,7 +13,6 @@ pub mod trip;
|
||||
pub mod tripdetails;
|
||||
pub mod user;
|
||||
pub mod usertrip;
|
||||
//pub mod users;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct Day {
|
||||
|
@ -1,61 +0,0 @@
|
||||
pub struct Users {
|
||||
users: Vec<User>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {}
|
||||
|
||||
//#[rocket::async_trait]
|
||||
//impl<'r> FromRequest<'r> for User {
|
||||
// type Error = Error;
|
||||
//
|
||||
// async fn from_request(req: &'r Request<'_>) -> request::Outcome<Self, Self::Error> {
|
||||
// //TODO: https://betterprogramming.pub/building-the-rust-web-app-multiple-users-and-authentication-5ca5988ddfe4
|
||||
// }
|
||||
//}
|
||||
|
||||
impl Deref for Users {
|
||||
type Target = Vec<User>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.users
|
||||
}
|
||||
}
|
||||
|
||||
impl Users {
|
||||
pub async fn new(pool: &SqlitePool) -> Result<Self, sqlx::Error> {
|
||||
let users: Vec<User> = sqlx::query_as!(
|
||||
User,
|
||||
r#"
|
||||
SELECT id, name, pw, is_cox, is_admin, is_guest
|
||||
FROM user
|
||||
"#,
|
||||
)
|
||||
.fetch_all(pool)
|
||||
.await?;
|
||||
|
||||
Ok(Self { users })
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::Users;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[sqlx::test]
|
||||
fn user_with_test_db() {
|
||||
let pool = SqlitePool::connect(":memory:").await.unwrap();
|
||||
sqlx::query_file!("./migration.sql")
|
||||
.execute(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
sqlx::query_file!("./seeds.sql")
|
||||
.execute(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let users = Users::new(&pool).await.unwrap();
|
||||
assert_eq!(users.len(), 4);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user