not going to use transactions anymore

This commit is contained in:
Mika 2025-06-17 13:19:17 +02:00
parent 1472572e3d
commit e383615150
3 changed files with 3 additions and 19 deletions

View file

@ -1,7 +1,5 @@
use backend::Database;
use lazy_static::lazy_static;
use sea_orm::{DatabaseTransaction, TransactionTrait};
use std::future::Future;
use testcontainers::ContainerAsync;
use testcontainers_modules::{postgres::Postgres, redis::Redis};
@ -31,17 +29,3 @@ pub async fn get_database() -> &'static Database {
&state.database
}
pub async fn with_transaction<F, Fut, R>(test: F) -> R
where
F: FnOnce(DatabaseTransaction) -> Fut,
Fut: Future<Output = R>,
{
let db = get_database().await;
let tx = db
.connection()
.begin()
.await
.expect("Failed to start transaction");
test(tx).await
}

View file

@ -2,7 +2,7 @@ use actix_web::{App, http::header, test, web};
use backend::controller;
use serde::{Deserialize, Serialize};
use crate::common::test_helpers::{get_database, with_transaction};
use crate::common::test_helpers::get_database;
#[cfg(test)]
mod tests {

View file

@ -6,10 +6,10 @@ mod tests {
use actix_web::{App, test, web};
use backend::controller;
use crate::common::test_helpers::{get_database, with_transaction};
use crate::common::test_helpers::get_database;
#[actix_web::test]
async fn test_auth_with_transaction() {
async fn test_ok() {
let db = get_database().await;
let app = test::init_service(