Skip to content

Commit

Permalink
Fix template env
Browse files Browse the repository at this point in the history
  • Loading branch information
Cow-Van committed Feb 6, 2024
1 parent afe5d16 commit 2d7059c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
40 changes: 21 additions & 19 deletions src/integration-tests/helpers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 };
7 changes: 6 additions & 1 deletion template.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ PORT=
DB_HOST=
DB_USER=
DB_PASS=
DB_NAME=
DB_NAME=

TEST_DB_HOST=
TEST_DB_USER=
TEST_DB_PASS=
TEST_DB_NAME=

0 comments on commit 2d7059c

Please sign in to comment.