Saving tests
Rust Build / Test Suite (pull_request) Successful in 44s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Check (pull_request) Successful in 1m15s
Rust Build / Clippy (pull_request) Successful in 1m45s
Rust Build / build (pull_request) Successful in 1m48s

This commit is contained in:
2026-06-12 10:32:37 -04:00
parent e95d5ba468
commit 4459e1062a
+20 -10
View File
@@ -187,7 +187,12 @@ mod util {
} }
} }
async fn register_user( mod flow {
use super::callers;
use super::requests;
use super::util;
pub async fn register_user(
app: &axum::Router, app: &axum::Router,
) -> Result<textsender_models::user::User, std::io::Error> { ) -> Result<textsender_models::user::User, std::io::Error> {
match requests::register_user(&app).await { match requests::register_user(&app).await {
@@ -217,7 +222,7 @@ async fn register_user(
} }
} }
async fn login_user( pub async fn login_user(
app: &axum::Router, app: &axum::Router,
username: &str, username: &str,
password: &str, password: &str,
@@ -230,7 +235,9 @@ async fn login_user(
response.status() response.status()
))) )))
} else { } else {
match util::convert_response::<callers::login::response::LoginResponse>(response) match util::convert_response::<callers::login::response::LoginResponse>(
response,
)
.await .await
{ {
Ok(response) => { Ok(response) => {
@@ -249,7 +256,7 @@ async fn login_user(
} }
} }
async fn register_service_user( pub async fn register_service_user(
app: &axum::Router, app: &axum::Router,
) -> Result<textsender_models::user::ServiceUser, std::io::Error> { ) -> Result<textsender_models::user::ServiceUser, std::io::Error> {
match requests::register_service_user(&app).await { match requests::register_service_user(&app).await {
@@ -281,7 +288,7 @@ async fn register_service_user(
} }
} }
async fn login_service_user( pub async fn login_service_user(
app: &axum::Router, app: &axum::Router,
username: &str, username: &str,
passphrase: &str, passphrase: &str,
@@ -314,6 +321,7 @@ async fn login_service_user(
Err(err) => Err(std::io::Error::other(err.to_string())), Err(err) => Err(std::io::Error::other(err.to_string())),
} }
} }
}
#[tokio::test] #[tokio::test]
async fn test_register_user() { async fn test_register_user() {
@@ -335,7 +343,7 @@ async fn test_register_user() {
let app = init::routes().await.layer(axum::Extension(pool)); let app = init::routes().await.layer(axum::Extension(pool));
match register_user(&app).await { match flow::register_user(&app).await {
Ok(returned_user) => { Ok(returned_user) => {
assert_eq!( assert_eq!(
TEST_USERNAME, returned_user.username, TEST_USERNAME, returned_user.username,
@@ -375,8 +383,8 @@ async fn test_login_user() {
let app = init::routes().await.layer(axum::Extension(pool)); let app = init::routes().await.layer(axum::Extension(pool));
match register_user(&app).await { match flow::register_user(&app).await {
Ok(user) => match login_user(&app, &user.username, TEST_PASSWORD).await { Ok(user) => match flow::login_user(&app, &user.username, TEST_PASSWORD).await {
Ok(login_result) => { Ok(login_result) => {
assert_eq!( assert_eq!(
false, false,
@@ -474,14 +482,16 @@ async fn test_login_service_user() {
let app = init::routes().await.layer(axum::Extension(pool)); let app = init::routes().await.layer(axum::Extension(pool));
match register_service_user(&app).await { match flow::register_service_user(&app).await {
Ok(user) => { Ok(user) => {
assert_eq!( assert_eq!(
false, false,
user.id.is_nil(), user.id.is_nil(),
"The service user id should not be nil" "The service user id should not be nil"
); );
match login_service_user(&app, TEST_SERVICE_USERNAME, TEST_SERVICE_PASSPHRASE).await { match flow::login_service_user(&app, TEST_SERVICE_USERNAME, TEST_SERVICE_PASSPHRASE)
.await
{
Ok(login_result) => { Ok(login_result) => {
assert_eq!( assert_eq!(
false, false,