From db856746011c5659f53db5f0a06510428b9c229f Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Sun, 26 Nov 2023 23:25:56 -0500 Subject: [PATCH] Update test database mocking --- src/database.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/database.rs b/src/database.rs index 22c0f3f..a3054f1 100644 --- a/src/database.rs +++ b/src/database.rs @@ -656,19 +656,41 @@ pub mod tests { // Mock a database file in transient memory pub fn mock_datasets() -> sqlite::Result { - let query = "PRAGMA foreign_keys = ON; + let query = "PRAGMA foreign_keys = ON; CREATE TABLE IF NOT EXISTS datasets ( name TEXT UNIQUE NOT NULL, last_sync INTEGER NOT NULL, game_id INTEGER NOT NULL, game_name TEXT NOT NULL, + game_slug TEXT NOT NULL, country TEXT, state TEXT, + set_limit INTEGER NOT NULL, decay_rate REAL NOT NULL, + adj_decay_rate REAL NOT NULL, period REAL NOT NULL, tau REAL NOT NULL -) STRICT;"; +) STRICT; + +CREATE TABLE IF NOT EXISTS players ( + id INTEGER PRIMARY KEY, + discrim TEXT UNIQUE NOT NULL, + name TEXT NOT NULL, + prefix TEXT +) STRICT; + +CREATE TABLE IF NOT EXISTS events ( + id INTEGER PRIMARY KEY, + slug TEXT NOT NULL +) STRICT; + +CREATE TABLE IF NOT EXISTS sets ( + id TEXT UNIQUE NOT NULL, + event INTEGER NOT NULL, + FOREIGN KEY(event) REFERENCES events +) STRICT; +"; let connection = sqlite::open(":memory:")?; connection.execute(query)?;