Move api tests to v2 namespace

This commit is contained in:
Blade Barringer
2015-11-03 08:31:20 -06:00
parent 2713b0f26f
commit 8c95de0835
30 changed files with 42 additions and 38 deletions

View File

@@ -15,7 +15,7 @@ let server;
const TEST_DB_URI = `mongodb://localhost/${TEST_DB}` const TEST_DB_URI = `mongodb://localhost/${TEST_DB}`
const API_TEST_COMMAND = 'mocha test/api --recursive --compilers js:babel/register'; const API_V2_TEST_COMMAND = 'mocha test/api/v2 --recursive --compilers js:babel/register';
const LEGACY_API_TEST_COMMAND = 'mocha test/api-legacy'; const LEGACY_API_TEST_COMMAND = 'mocha test/api-legacy';
const COMMON_TEST_COMMAND = 'mocha test/common --compilers coffee:coffee-script'; const COMMON_TEST_COMMAND = 'mocha test/common --compilers coffee:coffee-script';
const CONTENT_TEST_COMMAND = 'mocha test/content --compilers js:babel/register'; const CONTENT_TEST_COMMAND = 'mocha test/content --compilers js:babel/register';
@@ -293,12 +293,16 @@ gulp.task('test:e2e:safe', ['test:prepare', 'test:prepare:server'], (cb) => {
}); });
}); });
gulp.task('test:api', ['test:prepare:server'], (done) => { gulp.task('test:api-v2', ['test:prepare:server'], (done) => {
runIntegrationTestsWithMocha('./test/api/v2/**/*.js')
});
function runIntegrationTestsWithMocha(files) {
require('../test/helpers/globals.helper'); require('../test/helpers/globals.helper');
awaitPort(TEST_SERVER_PORT).then(() => { awaitPort(TEST_SERVER_PORT).then(() => {
let mocha = new Mocha({reporter: 'spec'}); let mocha = new Mocha({reporter: 'spec'});
let tests = glob('./test/api/**/*.js'); let tests = glob(files);
tests.forEach((test) => { tests.forEach((test) => {
delete require.cache[resolve(test)]; delete require.cache[resolve(test)];
@@ -313,17 +317,17 @@ gulp.task('test:api', ['test:prepare:server'], (done) => {
done(); done();
}); });
}); });
}); }
gulp.task('test:api:watch', ['test:prepare:server'], () => { gulp.task('test:api-v2:watch', ['test:prepare:server'], () => {
process.env.RUN_INTEGRATION_TEST_FOREVER = true; process.env.RUN_INTEGRATION_TEST_FOREVER = true;
gulp.watch(['website/src/**', 'test/api/**'], ['test:api']); gulp.watch(['website/src/**', 'test/api/**'], ['test:api']);
}); });
gulp.task('test:api:safe', ['test:prepare:server'], (done) => { gulp.task('test:api-v2:safe', ['test:prepare:server'], (done) => {
awaitPort(TEST_SERVER_PORT).then(() => { awaitPort(TEST_SERVER_PORT).then(() => {
let runner = exec( let runner = exec(
testBin(API_TEST_COMMAND), testBin(API_V2_TEST_COMMAND),
(err, stdout, stderr) => { (err, stdout, stderr) => {
testResults.push({ testResults.push({
suite: 'API Specs\t', suite: 'API Specs\t',
@@ -345,7 +349,7 @@ gulp.task('test', [
'test:server_side:safe', 'test:server_side:safe',
'test:karma:safe', 'test:karma:safe',
'test:api-legacy:safe', 'test:api-legacy:safe',
'test:api:safe', 'test:api-v2:safe',
], () => { ], () => {
let totals = [0,0,0]; let totals = [0,0,0];

View File

@@ -19,15 +19,15 @@ $ npm install -g gulp
To run the api tests, make sure the mongo db is up and running and then type this on the command line: To run the api tests, make sure the mongo db is up and running and then type this on the command line:
```bash ```bash
$ gulp test:api $ gulp test:api-v2
``` ```
It may take a little while to get going, since it requires the web server to start up before the tests can run. It may take a little while to get going, since it requires the web server to start up before the tests can run.
You can also run a watch command for the api tests. This will allow the tests to re-run automatically when you make changes in the `/test/api/` or `/website/src/` directories. You can also run a watch command for the api tests. This will allow the tests to re-run automatically when you make changes in the `/test/api/v2/`.
```bash ```bash
$ gulp test:api:watch $ gulp test:api-v2:watch
``` ```
One caveat. If you have a severe syntax error in your files, the tests may fail to run, but they won't alert you that they are not running. If you ever find your test hanging for a while, run this to get the stackstrace. Once you've fixed the problem, you can resume running the watch comand. One caveat. If you have a severe syntax error in your files, the tests may fail to run, but they won't alert you that they are not running. If you ever find your test hanging for a while, run this to get the stackstrace. Once you've fixed the problem, you can resume running the watch comand.

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
resetHabiticaDB, resetHabiticaDB,
requester, requester,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
describe('GET /groups', () => { describe('GET /groups', () => {
const NUMBER_OF_PUBLIC_GUILDS = 3; const NUMBER_OF_PUBLIC_GUILDS = 3;

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
import { import {
find, find,
each each

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
describe('POST /groups', () => { describe('POST /groups', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
describe('POST /groups/:id', () => { describe('POST /groups/:id', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
import { each, find } from 'lodash'; import { each, find } from 'lodash';
describe('POST /groups/:id/join', () => { describe('POST /groups/:id/join', () => {

View File

@@ -4,7 +4,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
import { find } from 'lodash'; import { find } from 'lodash';
describe('POST /groups/:id/leave', () => { describe('POST /groups/:id/leave', () => {

View File

@@ -4,7 +4,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
describe('POST /groups/:id/removeMember', () => { describe('POST /groups/:id/removeMember', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('DELETE /groups/:id/chat', () => { describe('DELETE /groups/:id/chat', () => {
let api, group, message, user; let api, group, message, user;

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('GET /groups/:id/chat', () => { describe('GET /groups/:id/chat', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('POST /groups/:id/chat', () => { describe('POST /groups/:id/chat', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('POST /groups/:id/chat/:id/flag', () => { describe('POST /groups/:id/chat/:id/flag', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('POST /groups/:id/chat/:id/like', () => { describe('POST /groups/:id/chat/:id/like', () => {

View File

@@ -2,7 +2,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
import {v4 as generateRandomUserName} from 'uuid'; import {v4 as generateRandomUserName} from 'uuid';
describe('POST /register', () => { describe('POST /register', () => {

View File

@@ -1,4 +1,4 @@
import {requester} from '../../helpers/api.helper'; import {requester} from '../../../helpers/api-integration.helper';
describe('Status', () => { describe('Status', () => {

View File

@@ -4,7 +4,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
describe('DELETE /user', () => { describe('DELETE /user', () => {
let api, user; let api, user;

View File

@@ -1,7 +1,7 @@
import { import {
generateUser, generateUser,
requester, requester,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
describe('GET /user', () => { describe('GET /user', () => {
let user; let user;

View File

@@ -1,7 +1,7 @@
import { import {
generateUser, generateUser,
requester, requester,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
describe('GET /user/tags', () => { describe('GET /user/tags', () => {
let api, user; let api, user;

View File

@@ -2,7 +2,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
describe('GET /user/tags/id', () => { describe('GET /user/tags/id', () => {
let api, user; let api, user;

View File

@@ -2,7 +2,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../helpers/api.helper'; } from '../../../helpers/api-integration.helper';
import { each } from 'lodash'; import { each } from 'lodash';

View File

@@ -1,7 +1,7 @@
import { import {
generateUser, generateUser,
requester, requester,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
import { each } from 'lodash'; import { each } from 'lodash';
describe('GET /user/anonymized', () => { describe('GET /user/anonymized', () => {

View File

@@ -2,7 +2,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
import { each } from 'lodash'; import { each } from 'lodash';

View File

@@ -1,7 +1,7 @@
import { import {
generateUser, generateUser,
requester, requester,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('POST /user/pushDevice', () => { describe('POST /user/pushDevice', () => {
let api; let api;

View File

@@ -2,7 +2,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('DELETE /user/tasks/:id', () => { describe('DELETE /user/tasks/:id', () => {
let api, user, task; let api, user, task;

View File

@@ -2,7 +2,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('GET /user/tasks/', () => { describe('GET /user/tasks/', () => {
let api, user; let api, user;

View File

@@ -2,7 +2,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('GET /user/tasks/:id', () => { describe('GET /user/tasks/:id', () => {
let api, user, task; let api, user, task;

View File

@@ -2,7 +2,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('POST /user/tasks', () => { describe('POST /user/tasks', () => {

View File

@@ -2,7 +2,7 @@ import {
generateUser, generateUser,
requester, requester,
translate as t, translate as t,
} from '../../../helpers/api.helper'; } from '../../../../helpers/api-integration.helper';
describe('PUT /user/tasks/:id', () => { describe('PUT /user/tasks/:id', () => {
let api, user, task; let api, user, task;