metadata unit test

This commit is contained in:
Simon Tokumine 2012-06-01 20:46:38 +01:00
parent 3541873a66
commit 0313b7b1ac
3 changed files with 17 additions and 21 deletions

View File

@ -1,12 +1,19 @@
cartodb-sql-api tests cartodb-sql-api tests
-- ---------------------
Tests require you create a test database and set some redis keys before, Tests require you create a test database and set some redis keys before,
you can execute prepare_db.sh script, it will create database, users you can execute prepare_db.sh script, it will create database, users
and redis stuff for you. Be sure postgres and redis are running and redis stuff for you. Be sure postgres and redis are running
> cd test && ./prepare_db.sh > cd test && ./prepare_db.sh
once database is configured, run the tests with expresso:
Acceptance tests (need ctrl-C to exit)
--------------------------------------
> expresso test/acceptance/app.test.js > expresso test/acceptance/app.test.js
> expresso test/acceptance/app.auth.test.js
Unit tests
----------
> expresso test/unit/psql.tests.js

View File

@ -7,6 +7,8 @@ echo "HSET rails:users:vizzuality id 1" | redis-cli -n 5
echo "HSET rails:users:vizzuality database_name cartodb_test_user_1_db" | redis-cli -n 5 echo "HSET rails:users:vizzuality database_name cartodb_test_user_1_db" | redis-cli -n 5
echo "SADD rails:users:vizzuality:map_key 1234" | redis-cli -n 5 echo "SADD rails:users:vizzuality:map_key 1234" | redis-cli -n 5
echo "preparing postgres..." echo "preparing postgres..."
dropdb -Upostgres -hlocalhost cartodb_test_user_1_db dropdb -Upostgres -hlocalhost cartodb_test_user_1_db
createdb -Upostgres -hlocalhost -Ttemplate_postgis -Opostgres -EUTF8 cartodb_test_user_1_db createdb -Upostgres -hlocalhost -Ttemplate_postgis -Opostgres -EUTF8 cartodb_test_user_1_db

View File

@ -1,16 +1,3 @@
/**
* User: simon
* Date: 24/08/2011
* Time: 13:03
* Desc: Tests for the metadata model
*
* in order to run this test, please ensure you have set the following in Redis:
*
* SELECT 5
* HSET rails:users:simon id 5
* HSET rails:users:simon database_name simons_database
*/
require('../helper'); require('../helper');
var _ = require('underscore') var _ = require('underscore')
@ -21,17 +8,17 @@ var _ = require('underscore')
, tests = module.exports = {}; , tests = module.exports = {};
tests['test can retrieve database name from header and redis'] = function(){ tests['test can retrieve database name from header and redis'] = function(){
var req = {headers: {host: 'simon.cartodb.com'}}; var req = {headers: {host: 'vizzuality.cartodb.com'}};
MetaData.getDatabase(req, function(err, data){ MetaData.getDatabase(req, function(err, data){
assert.equal(data, 'simons_database'); assert.equal(data, 'cartodb_test_user_1_db');
}); });
}; };
tests['test can retrieve id from header and redis'] = function(){ tests['test can retrieve id from header and redis'] = function(){
var req = {headers: {host: 'simon.cartodb.com'}}; var req = {headers: {host: 'vizzuality.cartodb.com'}};
MetaData.getId(req, function(err, data){ MetaData.getId(req, function(err, data){
assert.equal(data, '5'); assert.equal(data, '1');
}); });
}; };