Skip to content

Commit

Permalink
fixed filename
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi committed Dec 22, 2023
1 parent 6eee294 commit 0f33d69
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .badges/file-count.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions .badges/lines-of-code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion server/Database.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const sqlite3 = require('sqlite3').verbose();
// ============================ INIT SQLite DATABASE ============================
/** @type { import('sqlite3').Database } */
let db;
async function reinitializeIfNotExists(dbFile=':memory:', schemaFile='databaseSchema.sql') {
async function reinitializeIfNotExists(dbFile=':memory:', schemaFile='./server/databaseSchema.sql') {
const exists = dbFile != ':memory:' && fs.existsSync(dbFile);
if (exists) console.log("Database file found: " + dbFile);
if (db) await new Promise((resolve, reject) => {
Expand Down
4 changes: 2 additions & 2 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ app.use(cors(corsOptions))
app.use(express.static("public"));

// ============================ DATABASE ============================
const schemaFile = "./databaseSchema.sql"; // filepath for the database schema
require('./Database').reinitializeIfNotExists(process.env.DB_FILE, schemaFile);
const schemaFile = "./server/databaseSchema.sql"; // filepath for the database schema
module.exports.initPromise = require('./Database').reinitializeIfNotExists(process.env.DB_FILE, schemaFile);

// ============================ AUTHENTICATION ============================
const { authRouter } = require('./Auth');
Expand Down
3 changes: 2 additions & 1 deletion test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ describe('Client', () => {
before(async () => {
// spin up the server
process.env.DEVELOPMENT = supportsGoogleSignIn() ? 'false' : 'true';
({ listener } = require('../server/server.js'));
({ listener, initPromise } = require('../server/server.js'));
await initPromise;
port = listener.address().port;

// spin up the browser
Expand Down
6 changes: 3 additions & 3 deletions test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Server', () => {

describe('Database', () => {
beforeEach(async () => {
await reinitializeIfNotExists(TEST_DB_FILE, './databaseSchema.sql');
await reinitializeIfNotExists(TEST_DB_FILE, './server/databaseSchema.sql');
});

it('Should not return a value when asyncRun called', async () => {
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('Server', () => {

describe('Authentication', () => {
beforeEach(async () => {
await reinitializeIfNotExists(TEST_DB_FILE, './databaseSchema.sql');
await reinitializeIfNotExists(TEST_DB_FILE, './server/databaseSchema.sql');
});

it('Should return 400 Invalid Input when no token is provided', (t, done) => {
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('Server', () => {

describe('Business', () => {
beforeEach(async () => {
await reinitializeIfNotExists(TEST_DB_FILE, './databaseSchema.sql');
await reinitializeIfNotExists(TEST_DB_FILE, './server/databaseSchema.sql');
});

it('Should create a business with the correct values when createBusiness called', async (t) => {
Expand Down

0 comments on commit 0f33d69

Please sign in to comment.