| 236 | |
| 237 | #[cfg(test)] |
| 238 | pub async fn reset_db() -> Result<()> { |
| 239 | let c = get_async_db_conn().await?; |
| 240 | let mut c_wrapped: AsyncConnectionWrapper<AsyncDbPoolConnection> = |
| 241 | AsyncConnectionWrapper::from(c); |
| 242 | |
| 243 | tokio::task::spawn_blocking(move || -> Result<()> { |
| 244 | c_wrapped |
| 245 | .revert_all_migrations(MIGRATIONS) |
| 246 | .map_err(|e| anyhow!("During revert: {}", e))?; |
| 247 | c_wrapped |
| 248 | .run_pending_migrations(MIGRATIONS) |
| 249 | .map_err(|e| anyhow!("During run: {}", e))?; |
| 250 | |
| 251 | Ok(()) |
| 252 | }) |
| 253 | .await? |
| 254 | } |
| 255 | |
| 256 | #[cfg(test)] |
| 257 | pub async fn reset_redis() -> Result<()> { |