Skip to content

Commit

Permalink
ensure databases properly reinitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Nov 7, 2023
1 parent fa45312 commit 1a3afd9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 54 deletions.
42 changes: 14 additions & 28 deletions test/0.purgeTestingDatabases.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
import * as assert from 'node:assert';
import { unlink } from 'node:fs';
import { unlink } from 'node:fs/promises';
import { parkingDB_testing, nhtsaDB_testing } from '../data/databasePaths.js';
import { initNHTSADB } from '../database/nhtsaDB/initializeDatabase.js';
import { initializeDatabase as initializeParkingDatabase } from '../database/parkingDB/initializeDatabase.js';
describe('Reinitialize ' + parkingDB_testing, () => {
it('Purges ' + parkingDB_testing, (done) => {
unlink(parkingDB_testing, (error) => {
if (error) {
assert.fail();
}
else {
assert.ok(true);
}
done();
});
});
it('Creates ' + parkingDB_testing, () => {
describe('Reinitialize databases', () => {
it(`Reinitialize ${parkingDB_testing}`, () => {
try {
void unlink(parkingDB_testing);
}
catch {
}
const success = initializeParkingDatabase();
assert.ok(success);
});
});
describe('Reinitialize ' + nhtsaDB_testing, () => {
it('Purges ' + nhtsaDB_testing, (done) => {
unlink(nhtsaDB_testing, (error) => {
if (error) {
assert.fail();
}
else {
assert.ok(true);
}
done();
});
});
it('Creates ' + nhtsaDB_testing, () => {
it(`Reinitialize ${nhtsaDB_testing}`, () => {
try {
void unlink(nhtsaDB_testing);
}
catch {
}
const success = initNHTSADB();
assert.ok(success);
});
Expand Down
40 changes: 14 additions & 26 deletions test/0.purgeTestingDatabases.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
import * as assert from 'node:assert'
import { unlink } from 'node:fs'
import { unlink } from 'node:fs/promises'

import { parkingDB_testing, nhtsaDB_testing } from '../data/databasePaths.js'
import { initNHTSADB } from '../database/nhtsaDB/initializeDatabase.js'
import { initializeDatabase as initializeParkingDatabase } from '../database/parkingDB/initializeDatabase.js'

describe('Reinitialize ' + parkingDB_testing, () => {
it('Purges ' + parkingDB_testing, (done) => {
unlink(parkingDB_testing, (error) => {
if (error) {
assert.fail()
} else {
assert.ok(true)
}
done()
})
})
describe('Reinitialize databases', () => {
it(`Reinitialize ${parkingDB_testing}`, () => {
try {
void unlink(parkingDB_testing)
} catch {
// ignore
}

it('Creates ' + parkingDB_testing, () => {
const success = initializeParkingDatabase()
assert.ok(success)
})
})

describe('Reinitialize ' + nhtsaDB_testing, () => {
it('Purges ' + nhtsaDB_testing, (done) => {
unlink(nhtsaDB_testing, (error) => {
if (error) {
assert.fail()
} else {
assert.ok(true)
}
done()
})
})
it(`Reinitialize ${nhtsaDB_testing}`, () => {
try {
void unlink(nhtsaDB_testing)
} catch {
// ignore
}

it('Creates ' + nhtsaDB_testing, () => {
const success = initNHTSADB()
assert.ok(success)
})
Expand Down

0 comments on commit 1a3afd9

Please sign in to comment.