From 0313b7b1ac6877f3ef53ebf8c00fd278e8d0372a Mon Sep 17 00:00:00 2001 From: Simon Tokumine Date: Fri, 1 Jun 2012 20:46:38 +0100 Subject: [PATCH] metadata unit test --- test/README.md | 15 +++++++++++---- test/prepare_db.sh | 2 ++ test/unit/metadata.test.js | 21 ++++----------------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/test/README.md b/test/README.md index 77f7c336..721c4853 100644 --- a/test/README.md +++ b/test/README.md @@ -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 \ No newline at end of file diff --git a/test/prepare_db.sh b/test/prepare_db.sh index 33618d03..c17d1b86 100755 --- a/test/prepare_db.sh +++ b/test/prepare_db.sh @@ -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 diff --git a/test/unit/metadata.test.js b/test/unit/metadata.test.js index e080e040..b233b82e 100644 --- a/test/unit/metadata.test.js +++ b/test/unit/metadata.test.js @@ -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'); }); };