From 128047723d42ecb7f0dbfcdf441dcc3241d9daa3 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sun, 23 May 2021 12:33:14 +0300 Subject: [PATCH] chore: remove sqlite database before test --- migra-cli/tests/commands.rs | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/migra-cli/tests/commands.rs b/migra-cli/tests/commands.rs index c7ca53a..f21ca2c 100644 --- a/migra-cli/tests/commands.rs +++ b/migra-cli/tests/commands.rs @@ -528,17 +528,19 @@ mod upgrade { })?; #[cfg(any(feature = "sqlite", feature = "rusqlite"))] - inner("sqlite_invalid", || { - use rusqlite::Connection; + remove_sqlite_db().and_then(|_| { + inner("sqlite_invalid", || { + use rusqlite::Connection; - let conn = Connection::open(SQLITE_URL)?; - let articles_res = conn.execute_batch("SELECT a.id FROM articles AS a"); - let persons_res = conn.execute_batch("SELECT p.id FROM persons AS p"); + let conn = Connection::open(SQLITE_URL)?; + let articles_res = conn.execute_batch("SELECT a.id FROM articles AS a"); + let persons_res = conn.execute_batch("SELECT p.id FROM persons AS p"); - assert!(articles_res.is_ok()); - assert!(persons_res.is_err()); + assert!(articles_res.is_ok()); + assert!(persons_res.is_err()); - Ok(()) + Ok(()) + }) })?; Ok(()) @@ -578,17 +580,19 @@ mod upgrade { })?; #[cfg(any(feature = "sqlite", feature = "rusqlite"))] - inner("sqlite_invalid", || { - use rusqlite::Connection; + remove_sqlite_db().and_then(|_| { + inner("sqlite_invalid", || { + use rusqlite::Connection; - let conn = Connection::open(SQLITE_URL)?; - let articles_res = conn.execute_batch("SELECT a.id FROM articles AS a"); - let persons_res = conn.execute_batch("SELECT p.id FROM persons AS p"); + let conn = Connection::open(SQLITE_URL)?; + let articles_res = conn.execute_batch("SELECT a.id FROM articles AS a"); + let persons_res = conn.execute_batch("SELECT p.id FROM persons AS p"); - assert!(articles_res.is_err()); - assert!(persons_res.is_err()); + assert!(articles_res.is_err()); + assert!(persons_res.is_err()); - Ok(()) + Ok(()) + }) })?; Ok(())