summaryrefslogtreecommitdiffstats
path: root/src/routes/register.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/register.rs')
-rw-r--r--src/routes/register.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/routes/register.rs b/src/routes/register.rs
index 1c0f82d..9a4f007 100644
--- a/src/routes/register.rs
+++ b/src/routes/register.rs
@@ -60,8 +60,6 @@ impl Register {
#[cfg(test)]
mod tests {
- use crate::init_router;
-
use super::*;
use axum::{
@@ -72,11 +70,15 @@ mod tests {
use sqlx::PgPool;
use tower::ServiceExt;
+ use crate::init_router;
+
const JWT_SECRET: &str = "test-jwt-secret-token";
const JWT_MAX_AGE: time::Duration = time::Duration::HOUR;
+ type TestResult<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
+
#[sqlx::test]
- async fn test_register_created(pool: PgPool) -> Result<(), Error> {
+ async fn test_register_created(pool: PgPool) -> TestResult {
let state = Arc::new(AppState {
pool,
jwt_secret: JWT_SECRET.to_string(),
@@ -94,9 +96,9 @@ mod tests {
.uri("/api/register")
.method("POST")
.header(header::CONTENT_TYPE, mime::APPLICATION_JSON.as_ref())
- .body(Body::from(serde_json::to_vec(&user).unwrap()))?;
+ .body(Body::from(serde_json::to_vec(&user)?))?;
- let response = router.oneshot(request).await.unwrap();
+ let response = router.oneshot(request).await?;
assert_eq!(StatusCode::CREATED, response.status());
@@ -110,7 +112,7 @@ mod tests {
}
#[sqlx::test(fixtures(path = "../../fixtures", scripts("users")))]
- async fn test_register_conflict(pool: PgPool) -> Result<(), Error> {
+ async fn test_register_conflict(pool: PgPool) -> TestResult {
let state = Arc::new(AppState {
pool,
jwt_secret: JWT_SECRET.to_string(),
@@ -128,9 +130,9 @@ mod tests {
.uri("/api/register")
.method("POST")
.header(header::CONTENT_TYPE, mime::APPLICATION_JSON.as_ref())
- .body(Body::from(serde_json::to_vec(&user).unwrap()))?;
+ .body(Body::from(serde_json::to_vec(&user)?))?;
- let response = router.oneshot(request).await.unwrap();
+ let response = router.oneshot(request).await?;
assert_eq!(StatusCode::CONFLICT, response.status());