feat: add user profile management with update and retrieval endpoints, enhance database setup for testing
This commit is contained in:
@@ -6,9 +6,15 @@ use user::test_user;
|
||||
|
||||
#[tokio::test]
|
||||
async fn user_main() {
|
||||
let db = setup_test_db("sqlite::memory:")
|
||||
.await
|
||||
.expect("Set up db failed!");
|
||||
std::env::set_var(
|
||||
"MANAGEMENT_DATABASE_URL",
|
||||
"postgres://postgres:postgres@localhost:5434/postgres",
|
||||
);
|
||||
std::env::set_var(
|
||||
"DATABASE_URL",
|
||||
"postgres://postgres:postgres@localhost:5434/postgres",
|
||||
);
|
||||
let db = setup_test_db().await.expect("Failed to set up test db");
|
||||
|
||||
test_user(&db).await;
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
use sea_orm::{DatabaseConnection, Unchanged};
|
||||
use sea_orm::{DatabaseConnection, TryIntoModel};
|
||||
|
||||
use app::persistence::user::create_user;
|
||||
use models::domains::user;
|
||||
use models::params::user::CreateUserParams;
|
||||
|
||||
pub(super) async fn test_user(db: &DatabaseConnection) {
|
||||
@@ -9,13 +8,12 @@ pub(super) async fn test_user(db: &DatabaseConnection) {
|
||||
username: "test".to_string(),
|
||||
password: "password".to_string(),
|
||||
};
|
||||
let user_model = create_user(db, params)
|
||||
.await
|
||||
.expect("Create user failed!")
|
||||
.try_into_model() // Convert ActiveModel to Model for easier checks
|
||||
.unwrap();
|
||||
|
||||
let user = create_user(db, params).await.expect("Create user failed!");
|
||||
let expected = user::ActiveModel {
|
||||
id: Unchanged(1),
|
||||
username: Unchanged("test".to_owned()),
|
||||
password_hash: Unchanged(None),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(user, expected);
|
||||
assert_eq!(user_model.id, 1);
|
||||
assert_eq!(user_model.username, "test");
|
||||
}
|
||||
|
Reference in New Issue
Block a user