Adjust api tests

This commit is contained in:
Blade Barringer
2015-11-06 21:28:19 -06:00
parent 18328c0c42
commit 303b88b6fa
2 changed files with 6 additions and 3 deletions

View File

@@ -297,6 +297,7 @@ gulp.task('test:e2e:safe', ['test:prepare', 'test:prepare:server'], (cb) => {
}); });
gulp.task('test:api-v2', ['test:prepare:server'], (done) => { gulp.task('test:api-v2', ['test:prepare:server'], (done) => {
process.env.API_VERSION = 'v2';
awaitPort(TEST_SERVER_PORT).then(() => { awaitPort(TEST_SERVER_PORT).then(() => {
runMochaTests('./test/api/v2/**/*.js', server, done) runMochaTests('./test/api/v2/**/*.js', server, done)
}); });
@@ -329,15 +330,16 @@ gulp.task('test:api-v3', ['test:api-v3:unit', 'test:api-v3:integration']);
gulp.task('test:api-v3:watch', ['test:api-v3:unit:watch', 'test:api-v3:integration:watch']); gulp.task('test:api-v3:watch', ['test:api-v3:unit:watch', 'test:api-v3:integration:watch']);
gulp.task('test:api-v3:unit', ['test:prepare:server'], (done) => { gulp.task('test:api-v3:unit', (done) => {
runMochaTests('./test/api/v3/unit/**/*.js', null, done) runMochaTests('./test/api/v3/unit/**/*.js', null, done)
}); });
gulp.task('test:api-v3:unit:watch', ['test:prepare:server'], () => { gulp.task('test:api-v3:unit:watch', () => {
gulp.watch(['website/src/**', 'test/api/v3/unit/**'], ['test:api-v3:unit']); gulp.watch(['website/src/**', 'test/api/v3/unit/**'], ['test:api-v3:unit']);
}); });
gulp.task('test:api-v3:integration', ['test:prepare:server'], (done) => { gulp.task('test:api-v3:integration', ['test:prepare:server'], (done) => {
process.env.API_VERSION = 'v3';
awaitPort(TEST_SERVER_PORT).then(() => { awaitPort(TEST_SERVER_PORT).then(() => {
runMochaTests('./test/api/v3/unit/**/*.js', server, done) runMochaTests('./test/api/v3/unit/**/*.js', server, done)
}); });

View File

@@ -208,9 +208,10 @@ export function resetHabiticaDB() {
} }
function _requestMaker(user, method, additionalSets) { function _requestMaker(user, method, additionalSets) {
const API_V = process.env.API_VERSION || 'v2'
return (route, send, query) => { return (route, send, query) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let request = superagent[method](`http://localhost:${API_TEST_SERVER_PORT}/api/v2${route}`) let request = superagent[method](`http://localhost:${API_TEST_SERVER_PORT}/api/${API_V}${route}`)
.accept('application/json'); .accept('application/json');
if (user && user._id && user.apiToken) { if (user && user._id && user.apiToken) {