summaryrefslogtreecommitdiff
path: root/schist_models/tests/common
diff options
context:
space:
mode:
authorJoe Carstairs <jcarstairs@scottlogic.com>2025-07-28 13:22:53 +0100
committerJoe Carstairs <jcarstairs@scottlogic.com>2025-07-28 13:30:27 +0100
commit2361adeb0ca77904138e3466d51c2f44cf6df613 (patch)
treef6e7192908f99fab62061913d8a1e9d2b918414b /schist_models/tests/common
parentc7ed1e61ce2218be0b9e60577454124c4e43a366 (diff)
Tidier folders
Diffstat (limited to 'schist_models/tests/common')
-rw-r--r--schist_models/tests/common/mod.rs1
-rw-r--r--schist_models/tests/common/test_context.rs44
2 files changed, 0 insertions, 45 deletions
diff --git a/schist_models/tests/common/mod.rs b/schist_models/tests/common/mod.rs
deleted file mode 100644
index 5ff67da..0000000
--- a/schist_models/tests/common/mod.rs
+++ /dev/null
@@ -1 +0,0 @@
-pub mod test_context;
diff --git a/schist_models/tests/common/test_context.rs b/schist_models/tests/common/test_context.rs
deleted file mode 100644
index fb4112d..0000000
--- a/schist_models/tests/common/test_context.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-use std::sync::atomic::{AtomicU64, Ordering};
-
-use diesel::{Connection, SqliteConnection};
-use diesel_migrations::MigrationHarness;
-use schist_queries::clear::clear;
-use schist_models::migrations::MIGRATIONS;
-
-pub struct TestContext {
- pub db_url: String,
-}
-
-static ID_COUNTER: AtomicU64 = AtomicU64::new(0);
-
-impl TestContext {
- pub fn new() -> Self {
- let db_url = Self::next_id() + ".sqlite";
-
- let connection = &mut SqliteConnection
- ::establish(&db_url)
- .expect("failed to connect to database");
-
- connection
- .run_pending_migrations(MIGRATIONS)
- .expect("failed to run migrations");
-
- clear(connection)
- .expect("failed to clear database");
-
- Self {
- db_url,
- }
- }
-
- fn next_id() -> String {
- ID_COUNTER.fetch_add(1, Ordering::Relaxed).to_string()
- }
-}
-
-impl Drop for TestContext {
- fn drop(&mut self) {
- std::fs::remove_file(&self.db_url)
- .expect(format!("failed to delete database {}", self.db_url).as_str());
- }
-}