Run tests with "make check" (#21)
This commit is contained in:
+1
-1
@@ -33,6 +33,6 @@
|
||||
"mocha": "1.2.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "which expresso | sh"
|
||||
"test": "make check"
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Must match config.redis_pool.port in test/support/config.js
|
||||
REDIS_PORT=6333
|
||||
|
||||
cleanup() {
|
||||
echo "Cleaning up"
|
||||
kill ${PID_REDIS}
|
||||
}
|
||||
|
||||
cleanup_and_exit() {
|
||||
cleanup
|
||||
exit
|
||||
}
|
||||
|
||||
die() {
|
||||
msg=$1
|
||||
echo "${msg}" >&2
|
||||
cleanup
|
||||
exit 1
|
||||
}
|
||||
|
||||
trap 'cleanup_and_exit' 1 2 3 5 9 13
|
||||
|
||||
echo "Starting redis on port ${REDIS_PORT}"
|
||||
echo "port ${REDIS_PORT}" | redis-server - > test.log &
|
||||
PID_REDIS=$!
|
||||
|
||||
echo "Preparing the database"
|
||||
cd test; sh prepare_db.sh >> test.log || die "database preparation failure (see test.log)"; cd -;
|
||||
|
||||
PATH=node_modules/.bin/:$PATH
|
||||
|
||||
echo "Running unit test"
|
||||
mocha -u tdd test/unit/cartodb/redis_pool.test.js
|
||||
|
||||
echo "Running acceptance tests"
|
||||
# NOTE: leaks detected ! TODO: fix them
|
||||
mocha -u tdd --ignore-leaks test/acceptance/cache_validator.js
|
||||
mocha -u tdd --ignore-leaks test/acceptance/server.js
|
||||
|
||||
|
||||
cleanup
|
||||
+6
-5
@@ -17,11 +17,7 @@ die() {
|
||||
}
|
||||
|
||||
TEST_DB="cartodb_test_user_1_db"
|
||||
|
||||
echo "preparing redis..."
|
||||
echo "HSET rails:users:vizzuality id 1" | redis-cli -n 5
|
||||
echo "HSET rails:users:vizzuality database_name '${TEST_DB}'" | redis-cli -n 5
|
||||
echo 'HSET rails:${TEST_DB}:my_table infowindow "this, that, the other"' | redis-cli -n 0
|
||||
REDIS_PORT=6333
|
||||
|
||||
echo "preparing postgres..."
|
||||
dropdb "${TEST_DB}"
|
||||
@@ -29,4 +25,9 @@ createdb -Ttemplate_postgis -EUTF8 "${TEST_DB}" || die "Could not create test da
|
||||
psql "${TEST_DB}" < ./sql/windshaft.test.sql
|
||||
psql "${TEST_DB}" < ./sql/gadm4.sql
|
||||
|
||||
echo "preparing redis..."
|
||||
echo "HSET rails:users:vizzuality id 1" | redis-cli -p ${REDIS_PORT} -n 5
|
||||
echo "HSET rails:users:vizzuality database_name '${TEST_DB}'" | redis-cli -p ${REDIS_PORT} -n 5
|
||||
echo 'HSET rails:${TEST_DB}:my_table infowindow "this, that, the other"' | redis-cli -p ${REDIS_PORT} -n 0
|
||||
|
||||
echo "Finished preparing data. Run tests with expresso."
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
var _ = require('underscore');
|
||||
|
||||
module.exports = function(opts) {
|
||||
|
||||
var config = {
|
||||
redis_pool: {
|
||||
max: 10,
|
||||
idleTimeoutMillis: 1,
|
||||
reapIntervalMillis: 1,
|
||||
port: 6333 // TODO: read from test env ?
|
||||
}
|
||||
}
|
||||
|
||||
_.extend(config, opts || {});
|
||||
|
||||
return config;
|
||||
}();
|
||||
|
||||
@@ -6,11 +6,7 @@ var assert = require('../../support/assert')
|
||||
suite('redis_pool', function() {
|
||||
|
||||
// configure redis pool instance to use in tests
|
||||
var test_opts = {
|
||||
max: 10,
|
||||
idleTimeoutMillis: 1,
|
||||
reapIntervalMillis: 1
|
||||
};
|
||||
var test_opts = require('../../support/config').redis_pool;
|
||||
|
||||
var redis_pool = new RedisPool(test_opts);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user