Test tweaks
soaricarus_auth Build / Check (pull_request) Successful in 48s
soaricarus_auth Build / Rustfmt (pull_request) Successful in 48s
soaricarus_auth Build / Test Suite (pull_request) Successful in 56s
soaricarus_auth Build / Clippy (pull_request) Failing after 2m15s
soaricarus_auth Build / build (pull_request) Successful in 2m36s
soaricarus_auth Build / Check (pull_request) Successful in 48s
soaricarus_auth Build / Rustfmt (pull_request) Successful in 48s
soaricarus_auth Build / Test Suite (pull_request) Successful in 56s
soaricarus_auth Build / Clippy (pull_request) Failing after 2m15s
soaricarus_auth Build / build (pull_request) Successful in 2m36s
This commit is contained in:
+34
-2
@@ -251,6 +251,13 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
fn get_test_login_payload(usr: &callers::login::request::Request) -> serde_json::Value {
|
||||
json!({
|
||||
"username": &usr.username,
|
||||
"password": &usr.password,
|
||||
})
|
||||
}
|
||||
|
||||
pub mod requests {
|
||||
use tower::ServiceExt; // for `call`, `oneshot`, and `ready`
|
||||
|
||||
@@ -268,6 +275,21 @@ mod tests {
|
||||
|
||||
app.clone().oneshot(req).await
|
||||
}
|
||||
|
||||
pub async fn login(
|
||||
app: &axum::Router,
|
||||
usr: &super::callers::login::request::Request,
|
||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||
let payload = super::get_test_login_payload(&usr);
|
||||
let req = axum::http::Request::builder()
|
||||
.method(axum::http::Method::POST)
|
||||
.uri(crate::callers::endpoints::LOGIN)
|
||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||
.body(axum::body::Body::from(payload.to_string()))
|
||||
.unwrap();
|
||||
|
||||
app.clone().oneshot(req).await
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -398,11 +420,18 @@ mod tests {
|
||||
);
|
||||
assert!(returned_usr.date_created.is_some(), "Date Created is empty");
|
||||
|
||||
/*
|
||||
let login_payload = json!({
|
||||
"username": &usr.username,
|
||||
"password": &usr.password,
|
||||
});
|
||||
*/
|
||||
|
||||
let mut n_usr = callers::login::request::Request::default();
|
||||
n_usr.username = usr.username.clone();
|
||||
n_usr.password = usr.password.clone();
|
||||
|
||||
/*
|
||||
match app
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
@@ -413,7 +442,8 @@ mod tests {
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
*/
|
||||
match requests::login(&app, &n_usr).await {
|
||||
Ok(resp) => {
|
||||
assert_eq!(StatusCode::OK, resp.status(), "Status is not right");
|
||||
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
|
||||
@@ -577,7 +607,9 @@ mod tests {
|
||||
|
||||
db::init::migrations(&pool).await;
|
||||
|
||||
let app = init::routes().await.layer(axum::Extension(pool));
|
||||
let _app = init::routes().await.layer(axum::Extension(pool));
|
||||
|
||||
let _usr = get_test_register_request();
|
||||
|
||||
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||
}
|
||||
|
||||
+5
-4
@@ -57,7 +57,6 @@ pub mod user {
|
||||
.bind(password)
|
||||
.bind(user.id)
|
||||
.execute(pool)
|
||||
// .fetch_optional(pool)
|
||||
.await
|
||||
{
|
||||
Ok(r) => {
|
||||
@@ -240,9 +239,11 @@ pub mod salt {
|
||||
.await
|
||||
{
|
||||
Ok(row) => {
|
||||
let result = if row.rows_affected() > 0 { true } else { false };
|
||||
|
||||
Ok(result)
|
||||
if row.rows_affected() > 0 {
|
||||
Ok(true)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user