Merge pull request #72 from KevinMidboe/testing

Testing
This commit is contained in:
2018-01-09 16:56:45 +01:00
committed by GitHub
10 changed files with 61 additions and 11 deletions

View File

@@ -1,14 +1,14 @@
{
'dist': 'trusty',
'language': 'node_js',
'node_js': '6.9.5',
'node_js': '8.7.0',
'cache': 'yarn',
'scripts': [
npm run test
'npm run test'
],
'before_install': [
'cd seasoned_api',
],
'before_script': 'yarn',
'os': 'linux',
}
}

View File

@@ -1,5 +1,8 @@
# 🌶 seasonedShows
Your customly seasoned movie and show requester, downloader and organizer
[![Build Status](https://travis-ci.org/KevinMidboe/seasonedShows.svg?branch=testing)](https://travis-ci.org/KevinMidboe/seasonedShows)
[![DUB](https://img.shields.io/dub/l/vibe-d.svg)]()
Your customly *seasoned* movie and show requester, downloader and organizer.
## About
The goal of this project is to create a full custom stack that can to everything surround downloading, organizing and notifiyng of new media. From the top down we have a website using [tmdb](https://www.themoviedb.com) api to search for from over 350k movies and 70k tv shows. Using [hjone72](https://github.com/hjone72/PlexAuth) great PHP reverse proxy we can have a secure way of allowing users to login with their plex credentials which limits request capabilites to only users that are authenticated to use your plex library.

View File

@@ -0,0 +1,24 @@
{
"database": {
"host": "../shows.db"
},
"webserver": {
"port": 31459
},
"tmdb": {
"apiKey": ""
},
"raven": {
"DSN": ""
},
"mail": {
"host": "",
"user": "",
"password": "",
"user_pi": "",
"password_pi": ""
},
"authentication": {
"secret": "secret"
}
}

View File

@@ -3,13 +3,14 @@
"main": "webserver/server.js",
"scripts": {
"start": "cross-env SEASONED_CONFIG=conf/development.json NODE_PATH=. node src/webserver/server.js",
"test": "cross-env SEASONED_CONFIG=conf/development.json NODE_PATH=. mocha --recursive test/system",
"coverage": "cross-env PLANFLIX_CONFIG=conf/test.json NODE_PATH=. istanbul cover -x script/autogenerate-documentation.js --include-all-sources --dir test/.coverage node_modules/mocha/bin/_mocha --recursive test/**/* -- --report lcovonly && cat test/.coverage/lcov.info | coveralls && rm -rf test/.coverage",
"lint": "./node_modules/.bin/eslint src/webserver/"
},
"dependencies": {
"bcrypt-nodejs": "^0.0.3",
"body-parser": "~1.0.1",
"cross-env": "^3.1.3",
"eslint": "^4.9.0",
"express": "~4.0.0",
"jsonwebtoken": "^8.0.1",
"mongoose": "^3.6.13",
@@ -20,11 +21,16 @@
"raven": "^2.2.1",
"request": "^2.81.0",
"request-promise": "^4.2",
"sqlite": "^2.2.1",
"sqlite3": "^2.5.0"
"sqlite": "^2.9.0"
},
"devDependencies": {
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0"
"eslint-plugin-import": "^2.8.0",
"eslint": "^4.9.0",
"istanbul": "^0.4.5",
"mocha": "^3.1.0",
"supertest": "^2.0.1",
"supertest-as-promised": "^4.0.1"
}
}

View File

@@ -27,6 +27,11 @@ class Config {
const field = new Field(this.fields[section][option])
if (field.value === '') {
const envField = process.env[[section.toUpperCase(), option.toUpperCase()].join('_')]
if (envField !== undefined && envField.length !== 0) { return envField }
}
if (field.value === undefined) {
throw new Error(`${section} => ${option} is empty.`);
}

View File

@@ -4,7 +4,7 @@ const EnvironmentVariables = require('./environmentVariables.js');
class Field {
constructor(rawValue, environmentVariables) {
this.rawValue, rawValue;
this.rawValue = rawValue;
this.filters = new Filters(rawValue);
this.valueWithoutFilters = this.filters.removeFiltersFromValue();
this.environmentVariables = new EnvironmentVariables(environmentVariables);

View File

@@ -10,7 +10,7 @@ class Filters {
}
isEmpty() {
return !this.hasValidType() || this.filters.length === 0;
return !this.hasValidType() || this.value.length === 0;
}
has(filter) {

View File

@@ -0,0 +1,3 @@
DROP TABLE IF EXISTS user;
DROP TABLE IF EXISTS search_history;
DROP TABLE IF EXISTS requests;

View File

@@ -69,6 +69,15 @@ class SqliteDatabase {
return this.execute(setupSchema);
}
/**
* Tears down the database by running tearDown.sql file in schemas/.
* @returns {Promise}
*/
tearDown() {
const tearDownSchema = this.readSqlFile('tearDown.sql');
return this.execute(tearDownSchema);
}
/**
* Returns the file contents of a SQL file in schemas/.
* @returns {String}

View File

@@ -4,7 +4,7 @@ function resetDatabase() {
const database = new SqliteDatabase(':memory:');
return Promise.resolve()
.then(() => database.connect())
.then(() => database.tearDown())
// .then(() => database.tearDown())
.then(() => database.setUp());
}