metadata unit test
This commit is contained in:
parent
3541873a66
commit
0313b7b1ac
@ -1,12 +1,19 @@
|
||||
cartodb-sql-api tests
|
||||
--
|
||||
|
||||
---------------------
|
||||
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
|
||||
and redis stuff for you. Be sure postgres and redis are running
|
||||
|
||||
> 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.auth.test.js
|
||||
|
||||
|
||||
Unit tests
|
||||
----------
|
||||
|
||||
> expresso test/unit/psql.tests.js
|
@ -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 "SADD rails:users:vizzuality:map_key 1234" | redis-cli -n 5
|
||||
|
||||
|
||||
|
||||
echo "preparing postgres..."
|
||||
dropdb -Upostgres -hlocalhost cartodb_test_user_1_db
|
||||
createdb -Upostgres -hlocalhost -Ttemplate_postgis -Opostgres -EUTF8 cartodb_test_user_1_db
|
||||
|
@ -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');
|
||||
|
||||
var _ = require('underscore')
|
||||
@ -21,17 +8,17 @@ var _ = require('underscore')
|
||||
, tests = module.exports = {};
|
||||
|
||||
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){
|
||||
assert.equal(data, 'simons_database');
|
||||
assert.equal(data, 'cartodb_test_user_1_db');
|
||||
});
|
||||
};
|
||||
|
||||
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){
|
||||
assert.equal(data, '5');
|
||||
assert.equal(data, '1');
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user