diff --git a/src/integration-tests/helpers/database.ts b/src/integration-tests/helpers/database.ts index 8ec1774..e27f7f8 100644 --- a/src/integration-tests/helpers/database.ts +++ b/src/integration-tests/helpers/database.ts @@ -36,25 +36,7 @@ async function cleanUpDatabase() { async function resetTables() { await resetUsersTable(); - - - let sessionsParamList: any[][] = []; - fakeSessions.forEach((session: Session) => { - sessionsParamList.push([ - session.session_id, - session.user_id, - session.start_time, - session.end_time, - session.amended, - ]); - }); - - await db.query("TRUNCATE TABLE sessions"); - - const sql = `INSERT INTO sessions - (session_id, user_id, start_time, end_time, amended) - VALUES ?`; - await db.query(sql, [sessionsParamList]); + await resetSessionsTable(); } async function resetUsersTable() { @@ -84,4 +66,24 @@ async function resetUsersTable() { await db.query("ALTER TABLE IF EXISTS sessions ADD CONSTRAINT fk_session_user FOREIGN KEY (user_id) REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE"); // Add back foreign key constraint } +async function resetSessionsTable() { + let sessionsParamList: any[][] = []; + fakeSessions.forEach((session: Session) => { + sessionsParamList.push([ + session.session_id, + session.user_id, + session.start_time, + session.end_time, + session.amended, + ]); + }); + + await db.query("TRUNCATE TABLE sessions"); + + const sql = `INSERT INTO sessions + (session_id, user_id, start_time, end_time, amended) + VALUES ?`; + await db.query(sql, [sessionsParamList]); +} + export { setupDatabase, cleanUpDatabase, resetTables }; diff --git a/template.env b/template.env index 3d29754..8471b37 100644 --- a/template.env +++ b/template.env @@ -3,4 +3,9 @@ PORT= DB_HOST= DB_USER= DB_PASS= -DB_NAME= \ No newline at end of file +DB_NAME= + +TEST_DB_HOST= +TEST_DB_USER= +TEST_DB_PASS= +TEST_DB_NAME= \ No newline at end of file