Skip to content

Commit

Permalink
tests: regrouping all tests under a common folder
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlath committed Oct 17, 2018
1 parent 5330b24 commit e4349ce
Show file tree
Hide file tree
Showing 107 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion config/default.coffee
Expand Up @@ -180,7 +180,7 @@ module.exports = config =
updateEnabled: false
host: 'http://localhost:3213'
delay: 10000
# Set the path to the local repository to allow api_tests to start it
# Set the path to the local repository to allow API tests to start it
# if it isn't already online
localPath: '/path/to/repo'

Expand Down
2 changes: 1 addition & 1 deletion config/local-tests-alt.coffee
@@ -1,4 +1,4 @@
# Custom config for api_tests
# Custom config for API tests
# Use NODE_APP_INSTANCE=tests-alt to override local config with local-tests config

module.exports =
Expand Down
2 changes: 1 addition & 1 deletion config/universal_path.coffee
Expand Up @@ -38,7 +38,7 @@ module.exports =
controllers: '/server/controllers'
leveldb: '/db/leveldb'
couchdb: '/db/couchdb'
apiTests: '/api_tests'
apiTests: '/tests/api'
i18nSrc: '/server/lib/emails/i18n/src'
i18nArchive: '/server/lib/emails/i18n/src/archive'
i18nTransifex: '/server/lib/emails/i18n/src/transifex'
Expand Down
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -11,22 +11,22 @@
"couch2elastic4sync:reset": "./scripts/couch2elastic4sync/reset",
"create-entities-dump": "./scripts/dumps/prepare_entities_ndjson_dump",
"debug": "DEBUG=express:* coffee server.coffee",
"delete-api-test-databases": "./api_tests/scripts/delete_api_test_databases",
"delete-api-test-databases": "./tests/api/scripts/delete_databases",
"inspect": "node --inspect ./node_modules/.bin/coffee server.coffee",
"install-client": "./scripts/install-client",
"kill-tests-server": "./api_tests/scripts/kill_tests_server",
"lint": "coffeelint -f config/coffeelint.json --color always server.coffee server test api_tests db/couchdb scripts",
"kill-tests-server": "./tests/api/scripts/kill_tests_server",
"lint": "coffeelint -f config/coffeelint.json --color always server.coffee server tests db/couchdb scripts",
"lint-staged": "./scripts/lint-staged",
"migrator": "./scripts/migrator",
"postinstall": "./scripts/postinstall",
"preview-email": "./scripts/preview-email",
"reload": "touch server.coffee",
"reset-cache": "rm -rf db/leveldb && mkdir db/leveldb",
"start": "coffee server.coffee",
"start-tests-server": "./api_tests/scripts/start_tests_server",
"start-tests-server": "./tests/api/scripts/start_tests_server",
"test": "./scripts/test",
"test-api": "./api_tests/scripts/test_api",
"test-api-quick": "./api_tests/scripts/test_api_quick",
"test-api": "./tests/api/scripts/test_api",
"test-api-quick": "./tests/api/scripts/test_api_quick",
"test-watch": "./scripts/test --watch",
"update-i18n": "./scripts/update_i18n_all",
"update-toc": "doctoc README.md",
Expand Down
3 changes: 2 additions & 1 deletion scripts/test
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
options=$1
export NODE_ENV=tests; mocha --compilers coffee:coffee-script/register test/models/* test/libs/* test/controllers/* $options
export NODE_ENV=tests
mocha --compilers coffee:coffee-script/register tests/unit/models/* tests/unit/libs/* tests/unit/controllers/* $options
2 changes: 1 addition & 1 deletion server/lib/follow.coffee
Expand Up @@ -10,7 +10,7 @@ dbHost = CONFIG.db.fullHost()
{ reset:resetFollow, freeze:freezeFollow, delay:delayFollow } = CONFIG.db.follow

# Never follow in non-server mode.
# This behaviors allows, in api_tests environement, to have the tests server
# This behaviors allows, in API tests environement, to have the tests server
# following, while scripts being called directly by tests don't compete
# with the server
freezeFollow = freezeFollow or not CONFIG.serverMode
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -54,7 +54,7 @@ module.exports = API =
getRefreshedUser: (userPromise)->
userPromise
# Get the up-to-date user doc while keeping the cookie
# set by api_tests/fixtures/users
# set by tests/api/fixtures/users
.then (user)-> API.getUserWithCookie user.cookie

createUsername: ->
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
files=$@
# If no test file is passed as argument, run all tests
[ -z "$1" ] && files=api_tests/**/*test.coffee
[ -z "$1" ] && files=tests/api/**/*test.coffee

# Run the tests
export NODE_ENV=tests NODE_APP_INSTANCE=tests-alt; mocha --compilers coffee:coffee-script/register $files --timeout 20000
Expand Up @@ -9,7 +9,7 @@ entities_search_engine_host=$(node -p "require('config').entitiesSearchEngine.ho
curl -s "$entities_search_engine_host" > /dev/null && echo "entities search engine found" || \
# Using curly brackets to group those commands without starting a subshell from which exiting would be useless
# cf https://ss64.com/bash/syntax-brackets.html
{ ./api_tests/scripts/start_entities_search_engine && sleep 5 ; }
{ ./tests/api/scripts/start_entities_search_engine && sleep 5 ; }

# If the server is already up, return early
(curl -s "$test_host" > /dev/null || [ "$(cat run/3009)" == "starting" ]) &&
Expand Down
10 changes: 5 additions & 5 deletions api_tests/scripts/test_api → tests/api/scripts/test_api
@@ -1,13 +1,13 @@
#!/usr/bin/env sh

# In case they were running
./api_tests/scripts/kill_tests_server
./tests/api/scripts/kill_tests_server
# Deleting databases before the tests, so that tests can be run individually
# without having to check for the databases existance, has those will not have
# been deleted at the end of the tests
./api_tests/scripts/delete_tests_databases > /dev/null &&
./api_tests/scripts/start_tests_server &&
./api_tests/scripts/run_api_tests $@
./tests/api/scripts/delete_tests_databases > /dev/null &&
./tests/api/scripts/start_tests_server &&
./tests/api/scripts/run_api_tests $@

# Kill server, even if the tests fails
./api_tests/scripts/kill_tests_server
./tests/api/scripts/kill_tests_server
Expand Up @@ -10,5 +10,5 @@
(curl -s http://localhost:3009/api/tests > /dev/null &&
echo "tests server is online" ||
# If the server wasn't started before, start it
./api_tests/scripts/start_tests_server ) &&
./api_tests/scripts/run_api_tests $@
./tests/api/scripts/start_tests_server ) &&
./tests/api/scripts/run_api_tests $@
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -16,7 +16,7 @@ request = (method, endpoint, body, cookie)->

customAuthReq = (userPromise, method, endpoint, body)->
userPromise
# gets a user doc to which api_tests/fixtures/users added a cookie attribute
# gets a user doc to which tests/api/fixtures/users added a cookie attribute
.then (user)-> request method, endpoint, body, user.cookie

module.exports = { request, customAuthReq }
File renamed without changes.
Expand Up @@ -31,4 +31,4 @@ module.exports = API =
getAdminUser: getUserGetter 'admin', true
getUserGetter: getUserGetter

_.extend API, require('../../test/utils')
_.extend API, require('../../unit/utils')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e4349ce

Please sign in to comment.