@@ -922,8 +922,6 @@ pub mod tests {
922
922
use rstest:: rstest;
923
923
924
924
use super :: * ;
925
- use crate :: fixtures:: tests:: db_pool;
926
- use crate :: fixtures:: tests:: small_infra;
927
925
use crate :: generated_data:: infra_error:: InfraError ;
928
926
use crate :: generated_data:: infra_error:: InfraErrorType ;
929
927
use crate :: modelsv2:: fixtures:: create_small_infra;
@@ -1032,10 +1030,13 @@ pub mod tests {
1032
1030
#[ rstest]
1033
1031
async fn apply_edit_transaction_should_work ( ) {
1034
1032
// Init
1035
- let pg_db_pool = db_pool ( ) ;
1036
- let conn = & mut pg_db_pool. get ( ) . await . unwrap ( ) ;
1037
- let mut small_infra = small_infra ( pg_db_pool. clone ( ) ) . await ;
1038
- let mut infra_cache = InfraCache :: load ( conn, & small_infra. model ) . await . unwrap ( ) ;
1033
+ let app = TestAppBuilder :: default_app ( ) ;
1034
+ let db_pool = app. db_pool ( ) ;
1035
+
1036
+ let mut small_infra = create_small_infra ( & mut db_pool. get_ok ( ) ) . await ;
1037
+ let mut infra_cache = InfraCache :: load ( & mut db_pool. get_ok ( ) , & small_infra)
1038
+ . await
1039
+ . unwrap ( ) ;
1039
1040
1040
1041
// Calling "apply_edit" with a OK operation
1041
1042
let operations: Vec < Operation > = [
@@ -1053,10 +1054,14 @@ pub mod tests {
1053
1054
} ) ,
1054
1055
]
1055
1056
. to_vec ( ) ;
1056
- let result: Vec < InfraObject > =
1057
- apply_edit ( conn, & mut small_infra. model , & operations, & mut infra_cache)
1058
- . await
1059
- . unwrap ( ) ;
1057
+ let result: Vec < InfraObject > = apply_edit (
1058
+ & mut db_pool. get_ok ( ) ,
1059
+ & mut small_infra,
1060
+ & operations,
1061
+ & mut infra_cache,
1062
+ )
1063
+ . await
1064
+ . unwrap ( ) ;
1060
1065
1061
1066
// Check that the updated track has the new length
1062
1067
assert_eq ! ( 1234.0 , result[ 0 ] . get_data( ) [ "length" ] ) ;
@@ -1065,9 +1070,12 @@ pub mod tests {
1065
1070
#[ rstest]
1066
1071
async fn apply_edit_transaction_should_rollback ( ) {
1067
1072
// Init
1068
- let conn = & mut db_pool ( ) . get ( ) . await . unwrap ( ) ;
1069
- let mut small_infra = small_infra ( db_pool ( ) . clone ( ) ) . await ;
1070
- let mut infra_cache = InfraCache :: load ( conn, & small_infra. model ) . await . unwrap ( ) ;
1073
+ let app = TestAppBuilder :: default_app ( ) ;
1074
+ let db_pool = app. db_pool ( ) ;
1075
+ let mut small_infra = create_small_infra ( & mut db_pool. get_ok ( ) ) . await ;
1076
+ let mut infra_cache = InfraCache :: load ( & mut db_pool. get_ok ( ) , & small_infra)
1077
+ . await
1078
+ . unwrap ( ) ;
1071
1079
1072
1080
// Calling "apply_edit" with a first OK operation and a KO second one
1073
1081
let operations: Vec < Operation > = [
@@ -1097,15 +1105,24 @@ pub mod tests {
1097
1105
} ) ,
1098
1106
]
1099
1107
. to_vec ( ) ;
1100
- let result = apply_edit ( conn, & mut small_infra. model , & operations, & mut infra_cache) . await ;
1108
+ let result = apply_edit (
1109
+ & mut db_pool. get_ok ( ) ,
1110
+ & mut small_infra,
1111
+ & operations,
1112
+ & mut infra_cache,
1113
+ )
1114
+ . await ;
1101
1115
1102
1116
// Check that we have an error
1103
1117
assert ! ( result. is_err( ) ) ;
1104
1118
1105
1119
// Check that TA0 length is not changed
1106
1120
let res: Vec < ObjectQueryable > = small_infra
1107
- . model
1108
- . get_objects ( conn, ObjectType :: TrackSection , & vec ! [ "TA0" . to_string( ) ] )
1121
+ . get_objects (
1122
+ & mut db_pool. get_ok ( ) ,
1123
+ ObjectType :: TrackSection ,
1124
+ & vec ! [ "TA0" . to_string( ) ] ,
1125
+ )
1109
1126
. await
1110
1127
. unwrap ( ) ;
1111
1128
assert_eq ! ( 2000.0 , res[ 0 ] . railjson. as_object( ) . unwrap( ) [ "length" ] ) ;
0 commit comments