added db upgrade tests

This commit is contained in:
Joe Dowd
2020-08-31 02:52:12 +01:00
parent 82d59e159f
commit 88e6c6f93c
4 changed files with 25 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
BEGIN TRANSACTION;
/* Add version to config */
INSERT INTO config (key, value) VALUES("version", 1);
COMMIT;

12
test/cases/dbUpgrade.js Normal file
View File

@@ -0,0 +1,12 @@
const databases = require('../../src/databases/databases.js');
const db = databases.db;
const privateDB = databases.privateDB;
describe('dbUpgrade', () => {
it('Should update the database version when starting the application', (done) => {
let dbVersion = db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version']).value;
let privateVersion = privateDB.prepare('get', 'SELECT key, value FROM config where key = ?', ['version']).value;
if (dbVersion >= 1 && privateVersion >= 1) done();
else done('Versions are not at least 1. db is ' + dbVersion + ', private is ' + privateVersion);
});
});

View File

@@ -12,6 +12,12 @@ describe('getSegmentsByHash', () => {
db.exec(startOfQuery + "('getSegmentsByHash-1', 60, 70, 2, 'getSegmentsByHash-1', 'testman', 0, 50, 'sponsor', 0, '" + getHash('getSegmentsByHash-1', 1) + "')"); // hash = 3272fa85ee0927f6073ef6f07ad5f3146047c1abba794cfa364d65ab9921692b
});
it('Should update the database version when starting the application', (done) => {
let version = db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version']).value;
if (version > 2) done();
else done('Version isn\'t greater than 2. Version is ' + version);
});
it('Should be able to get a 200', (done) => {
request.get(utils.getbaseURL()
+ '/api/skipSegments/3272f?categories=["sponsor", "intro"]', null,

View File

@@ -22,7 +22,7 @@ describe('noSegmentRecords', () => {
it('Should update the database version when starting the application', (done) => {
let version = db.prepare('get', 'SELECT key, value FROM config where key = ?', ['version']).value;
if (version > 1) done();
else done('Version isn\'t greater that 1. Version is ' + version);
else done('Version isn\'t greater than 1. Version is ' + version);
});
it('Should be able to submit categorys not in video (http response)', (done) => {