Assert that the audit log contains at least one entry with `event` and `db_id`.
(
state: &SharedState,
event: nodedb::control::security::audit::AuditEvent,
db_id: Option<nodedb_types::id::DatabaseId>,
)
| 147 | |
| 148 | /// Assert that the audit log contains at least one entry with `event` and `db_id`. |
| 149 | pub fn assert_audit_has( |
| 150 | state: &SharedState, |
| 151 | event: nodedb::control::security::audit::AuditEvent, |
| 152 | db_id: Option<nodedb_types::id::DatabaseId>, |
| 153 | ) { |
| 154 | let log = state.audit.lock().unwrap_or_else(|p| p.into_inner()); |
| 155 | assert!( |
| 156 | log.all() |
| 157 | .iter() |
| 158 | .any(|e| e.event == event && e.database_id == db_id), |
| 159 | "expected audit event {event:?} for db {db_id:?}, got {:?}", |
| 160 | log.all() |
| 161 | .iter() |
| 162 | .map(|e| (e.event.clone(), e.database_id)) |
| 163 | .collect::<Vec<_>>() |
| 164 | ); |
| 165 | } |