Skip to content

Commit 3040c34

Browse files
committed
editoast: resolve rebase issues
1 parent 1c07371 commit 3040c34

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

editoast/src/generated_data/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ pub mod tests {
172172
use crate::modelsv2::DbConnectionPoolV2;
173173

174174
#[rstest] // Slow test
175+
#[serial_test::serial]
175176
async fn refresh_all_test() {
176177
let db_pool = DbConnectionPoolV2::for_tests();
177178
let infra = create_empty_infra(db_pool.get_ok().deref_mut()).await;

editoast/src/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,9 @@ async fn clone_infra(
592592
let new_name = infra_args
593593
.new_name
594594
.unwrap_or_else(|| format!("{} (clone)", infra.name));
595-
let cloned_infra = infra.clone(conn, new_name).await?;
595+
let cloned_infra = infra
596+
.clone(db_pool.get().await?.deref_mut(), new_name)
597+
.await?;
596598
println!(
597599
"✅ Infra {} (ID: {}) was successfully cloned",
598600
cloned_infra.name.bold(),

editoast/src/modelsv2/infra.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod splited_track_section_with_data;
77
mod voltage;
88

99
use std::ops::DerefMut;
10-
use std::pin::Pin;
1110

1211
use chrono::NaiveDateTime;
1312
use chrono::Utc;
@@ -17,6 +16,7 @@ use diesel::sql_query;
1716
use diesel::sql_types::BigInt;
1817
use diesel::ExpressionMethods;
1918
use diesel::QueryDsl;
19+
use diesel_async::AsyncConnection;
2020
use diesel_async::RunQueryDsl;
2121
use editoast_derive::ModelV2;
2222
use serde::Deserialize;
@@ -144,8 +144,8 @@ impl Infra {
144144
self.save(conn).await
145145
}
146146

147-
pub async fn clone(&self, conn: &mut DbConnection, new_name: String) -> Result<Infra> {
148-
conn.build_transaction().run(|conn| Box::pin(async {
147+
pub async fn clone(&self, connection: &mut DbConnection, new_name: String) -> Result<Infra> {
148+
connection.transaction(|conn| { Box::pin(async {
149149
// Duplicate infra shell
150150
let cloned_infra = <Self as Clone>::clone(self)
151151
.into_changeset()
@@ -229,7 +229,8 @@ impl Infra {
229229
}
230230

231231
Ok(cloned_infra)
232-
})).await
232+
})}
233+
).await
233234
}
234235

235236
/// Refreshes generated data if not up to date and returns whether they were refreshed.
@@ -359,6 +360,7 @@ pub mod tests {
359360
}
360361

361362
#[rstest]
363+
#[serial_test::serial]
362364
async fn clone_infra_with_new_name_returns_new_cloned_infra() {
363365
// GIVEN
364366
let db_pool = DbConnectionPoolV2::for_tests();
@@ -367,7 +369,7 @@ pub mod tests {
367369

368370
// WHEN
369371
let result = empty_infra
370-
.clone(db_pool.into(), infra_new_name.clone())
372+
.clone(db_pool.get_ok().deref_mut(), infra_new_name.clone())
371373
.await
372374
.expect("could not clone infra");
373375

editoast/src/views/infra/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ async fn clone(
341341
}
342342
})
343343
.await?;
344-
let cloned_infra = infra.clone(conn, name).await?;
344+
let cloned_infra = infra.clone(db_pool.get().await?.deref_mut(), name).await?;
345345
Ok(Json(cloned_infra.id))
346346
}
347347

@@ -658,6 +658,7 @@ pub mod tests {
658658
}
659659

660660
#[rstest]
661+
#[serial_test::serial]
661662
async fn infra_clone_empty() {
662663
let app = TestAppBuilder::default_app();
663664
let db_pool = app.db_pool();
@@ -682,6 +683,7 @@ pub mod tests {
682683
}
683684

684685
#[rstest] // Slow test
686+
#[serial_test::serial]
685687
async fn infra_clone() {
686688
let app = TestAppBuilder::default_app();
687689
let db_pool = app.db_pool();

0 commit comments

Comments
 (0)