@@ -7,7 +7,6 @@ mod splited_track_section_with_data;
7
7
mod voltage;
8
8
9
9
use std:: ops:: DerefMut ;
10
- use std:: pin:: Pin ;
11
10
12
11
use chrono:: NaiveDateTime ;
13
12
use chrono:: Utc ;
@@ -17,6 +16,7 @@ use diesel::sql_query;
17
16
use diesel:: sql_types:: BigInt ;
18
17
use diesel:: ExpressionMethods ;
19
18
use diesel:: QueryDsl ;
19
+ use diesel_async:: AsyncConnection ;
20
20
use diesel_async:: RunQueryDsl ;
21
21
use editoast_derive:: ModelV2 ;
22
22
use serde:: Deserialize ;
@@ -144,8 +144,8 @@ impl Infra {
144
144
self . save ( conn) . await
145
145
}
146
146
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 {
149
149
// Duplicate infra shell
150
150
let cloned_infra = <Self as Clone >:: clone ( self )
151
151
. into_changeset ( )
@@ -229,7 +229,8 @@ impl Infra {
229
229
}
230
230
231
231
Ok ( cloned_infra)
232
- } ) ) . await
232
+ } ) }
233
+ ) . await
233
234
}
234
235
235
236
/// Refreshes generated data if not up to date and returns whether they were refreshed.
@@ -359,6 +360,7 @@ pub mod tests {
359
360
}
360
361
361
362
#[ rstest]
363
+ #[ serial_test:: serial]
362
364
async fn clone_infra_with_new_name_returns_new_cloned_infra ( ) {
363
365
// GIVEN
364
366
let db_pool = DbConnectionPoolV2 :: for_tests ( ) ;
@@ -367,7 +369,7 @@ pub mod tests {
367
369
368
370
// WHEN
369
371
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 ( ) )
371
373
. await
372
374
. expect ( "could not clone infra" ) ;
373
375
0 commit comments