diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-01-03 23:39:00 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-01-03 23:48:42 +0100 |
| commit | 6354a463401d529c0a1d02264d1fa8ff4e251af5 (patch) | |
| tree | 77545ebb43d806668694d6bc4088e9fa97933053 /server/src/main.rs | |
| parent | 7494db93b9262c3d8330fd11631e711a1642b8fc (diff) | |
Add more tests
Use project_check_maintainer correctly, should not panic (by .unwrap)
but forward the error (by ?).
Diffstat (limited to 'server/src/main.rs')
| -rw-r--r-- | server/src/main.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/server/src/main.rs b/server/src/main.rs index 53cdb89..6f66866 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -272,9 +272,7 @@ async fn project_update( projectid: u64, data: Json<api_model::ProjectData<'_>>, ) -> Result<&'static str, Custom<&'static str>> { - project_check_maintainer(&mut db, session, projectid) - .await - .unwrap(); + project_check_maintainer(&mut db, session, projectid).await?; if data.title.is_none() && data.description.is_none() { // Nothing to update. Treat as "success". @@ -319,9 +317,7 @@ async fn project_user_add( userid: u64, data: Json<api_model::ProjectUserEntryData>, ) -> Result<&'static str, Custom<&'static str>> { - project_check_maintainer(&mut db, session, projectid) - .await - .unwrap(); + project_check_maintainer(&mut db, session, projectid).await?; sqlx::query!( "INSERT INTO project_users (project, user, default_role, maintainer) VALUES (?, ?, ?, ?)", @@ -361,9 +357,7 @@ async fn project_user_update( let need_maintainer = data.maintainer.is_some() || userid != session.user_id; if need_maintainer { - project_check_maintainer(&mut db, session, projectid) - .await - .unwrap(); + project_check_maintainer(&mut db, session, projectid).await?; } if data.default_role.is_none() && data.maintainer.is_none() { @@ -412,9 +406,7 @@ async fn project_user_del( let need_maintainer = userid != session.user_id; if need_maintainer { - project_check_maintainer(&mut db, session, projectid) - .await - .unwrap(); + project_check_maintainer(&mut db, session, projectid).await?; } sqlx::query!( |
