Skip to content

Commit 800d9c6

Browse files
committed
editoast: update test to be more independent
1 parent cf6ebac commit 800d9c6

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

editoast/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $ cargo run -- runserver
3232

3333
## Tests
3434

35-
In order to run tests, you need to have a postgresql database running.
35+
In order to run tests, you need to have a postgresql database and redis running.
3636

3737
To avoid thread conflicts while accessing the database, use the `--test-threads=1` option.
3838

editoast/src/main.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -717,28 +717,27 @@ mod tests {
717717
async fn test_electrical_profile_set_delete(
718718
#[future] electrical_profile_set: TestFixture<ElectricalProfileSet>,
719719
) {
720+
// GIVEN
720721
let pg_config = PostgresConfig::default();
721722
let electrical_profile_set = electrical_profile_set.await;
722723

723-
let mut conn = PgConnection::establish(&pg_config.url()).await.unwrap();
724-
let previous_length = ElectricalProfileSet::list_light(&mut conn)
725-
.await
726-
.unwrap()
727-
.len();
728-
729724
let args = DeleteProfileSetArgs {
730725
profile_set_ids: vec![electrical_profile_set.id()],
731726
};
727+
728+
// WHEN
732729
electrical_profile_set_delete(args, pg_config.clone())
733730
.await
734731
.unwrap();
735732

733+
// THEN
736734
let mut conn = PgConnection::establish(&pg_config.url()).await.unwrap();
737-
let new_length = ElectricalProfileSet::list_light(&mut conn)
735+
let empty = !ElectricalProfileSet::list_light(&mut conn)
738736
.await
739737
.unwrap()
740-
.len();
741-
assert_eq!(new_length, previous_length - 1);
738+
.iter()
739+
.any(|eps| eps.id == electrical_profile_set.id());
740+
assert!(empty);
742741
}
743742

744743
#[rstest]

0 commit comments

Comments
 (0)