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.rs27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/routes/register.rs b/src/routes/register.rs
index 286e70f..75819b0 100644
--- a/src/routes/register.rs
+++ b/src/routes/register.rs
@@ -1,4 +1,4 @@
-use std::{str::FromStr, sync::Arc};
+use std::str::FromStr;
use argon2::{
password_hash::{rand_core::OsRng, SaltString},
@@ -25,7 +25,7 @@ impl Register {
#[tracing::instrument(skip(password))]
pub async fn post(
self,
- State(state): State<Arc<AppState>>,
+ State(state): State<AppState>,
Json(RegisterSchema {
name,
email,
@@ -73,18 +73,16 @@ mod tests {
use sqlx::PgPool;
use tower::ServiceExt;
- use crate::init_router;
-
- const JWT_SECRET: &str = "test-jwt-secret-token";
-
- type TestResult<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
+ use crate::{
+ init_router,
+ tests::{setup_test_env, TestResult},
+ };
#[sqlx::test]
async fn test_register_created(pool: PgPool) -> TestResult {
- let state = Arc::new(AppState {
- pool,
- jwt_secret: JWT_SECRET.to_string(),
- });
+ setup_test_env();
+
+ let state = AppState { pool };
let router = init_router(state.clone());
let user = RegisterSchema {
@@ -114,10 +112,9 @@ mod tests {
#[sqlx::test(fixtures(path = "../../fixtures", scripts("users")))]
async fn test_register_conflict(pool: PgPool) -> TestResult {
- let state = Arc::new(AppState {
- pool,
- jwt_secret: JWT_SECRET.to_string(),
- });
+ setup_test_env();
+
+ let state = AppState { pool };
let router = init_router(state.clone());
let user = RegisterSchema {