diff options
Diffstat (limited to 'actualbudget_to_schist_transformer/tests/common/test_context.rs')
| -rw-r--r-- | actualbudget_to_schist_transformer/tests/common/test_context.rs | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/actualbudget_to_schist_transformer/tests/common/test_context.rs b/actualbudget_to_schist_transformer/tests/common/test_context.rs deleted file mode 100644 index e59c5f8..0000000 --- a/actualbudget_to_schist_transformer/tests/common/test_context.rs +++ /dev/null @@ -1,42 +0,0 @@ -use anyhow::Context; -use diesel::{Connection, SqliteConnection}; -use diesel_migrations::MigrationHarness; -use schist_queries::clear::clear; -use schist_models::migrations::MIGRATIONS; - -use super::{TEST_IN_DB_URL, TEST_OUT_DB_URL}; - -pub struct TestContext { -} - -impl TestContext { - pub fn new() -> Self { - let _in_connection = &mut SqliteConnection - ::establish(&TEST_IN_DB_URL) - .with_context(|| format!("failed to establish connection to in database at {}", TEST_IN_DB_URL)) - .unwrap(); - - let out_connection = &mut SqliteConnection - ::establish(&TEST_OUT_DB_URL) - .with_context(|| format!("failed to establish connection to out database at {}", TEST_OUT_DB_URL)) - .unwrap(); - - out_connection - .run_pending_migrations(MIGRATIONS) - .expect("failed to run migrations on out database"); - - clear(out_connection) - .expect("failed to clear database"); - - Self { - } - } -} - -impl Drop for TestContext { - fn drop(&mut self) { - std::fs::remove_file(&TEST_OUT_DB_URL) - .with_context(|| format!("failed to delete out database at {}", TEST_OUT_DB_URL)) - .unwrap(); - } -} |
