Improve test_migration_flags, add EvTracker to test_utils

This commit is contained in:
Hocuri
2021-06-11 16:28:39 +02:00
committed by bjoern
parent 991d15615e
commit d12d9d94d6
2 changed files with 55 additions and 1 deletions

View File

@@ -198,7 +198,7 @@ impl Sql {
}
}
info!(context, "Opened {:?}.", dbfile);
info!(context, "Opened database {:?}.", dbfile);
Ok(())
}
@@ -806,6 +806,8 @@ mod test {
#[async_std::test]
async fn test_migration_flags() -> Result<()> {
let t = TestContext::new().await;
let events = t.new_evtracker().await;
events.get_info_contains("Opened database").await;
// as migrations::run() was already executed on context creation,
// another call should not result in any action needed.
@@ -817,6 +819,20 @@ mod test {
assert!(!disable_server_delete);
assert!(!recode_avatar);
info!(&t, "test_migration_flags: XXX");
loop {
if let EventType::Info(info) = events.recv().await.unwrap() {
assert!(
!info.contains("[migration]"),
"Migrations were run twice, you probably forgot to update the db version"
);
if info.contains("test_migration_flags: XXX") {
break;
}
}
}
Ok(())
}
}