defined test database

This commit is contained in:
Jörn-Michael Miehe 2019-05-10 14:34:58 +02:00
parent 9d1e790a0d
commit b60ac2105a
2 changed files with 17 additions and 13 deletions

View file

@ -43,18 +43,22 @@ class FFTCGDB
''', (err) => ''', (err) =>
logger.error err.message if err logger.error err.message if err
@db.run 'DROP TABLE IF EXISTS decks;', (err) => @db.run 'DROP TABLE IF EXISTS decks;', (err) =>
logger.error err.message if err logger.error err.message if err
@db.run ''' @db.run '''
CREATE TABLE decks ( CREATE TABLE decks (
deck integer PRIMARY KEY, deck integer PRIMARY KEY,
user integer NOT NULL, user integer NOT NULL,
json text, json text,
FOREIGN KEY (user) REFERENCES users (user) FOREIGN KEY (user) REFERENCES users (user)
ON DELETE CASCADE ON DELETE CASCADE
); );
''', (err) => ''', (err) =>
logger.error err.message if err logger.error err.message if err
@db.run '''INSERT INTO users VALUES(1,'jmm','$2b$13$jgDdHHDWqq1RV6PXxf7aOO6AbxqY6tbxIADyIO0FeXt2BlKQCCMzS',NULL);'''
@db.run '''INSERT INTO decks VALUES(1,1,'{"name":"frosch"}');'''
@db.run '''INSERT INTO decks VALUES(2,1,'{"name":"frosch2"}');'''
logger.info 'OK clear' logger.info 'OK clear'

View file

@ -56,7 +56,7 @@ class FFTCGSESSION
else else
@db.get digest, (err, res) -> @db.get digest, (err, res) ->
logger.info "OK '#{digest}' resumed" logger.debug "OK '#{digest}' resumed"
resolve (JSON.parse res) resolve (JSON.parse res)
module.exports = new FFTCGSESSION module.exports = new FFTCGSESSION