From b428a7be9a4f1496289ea1c71cd39f3a18d9b236 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 11 Nov 2013 17:49:05 +0100 Subject: [PATCH] Add test for redis-specifid database_host. Closes #88 --- test/acceptance/server.js | 36 ++++++++++++++++++++++++++++++++++++ test/support/prepare_db.sh | 7 +++++++ 2 files changed, 43 insertions(+) diff --git a/test/acceptance/server.js b/test/acceptance/server.js index 465d6774..47cdd737 100644 --- a/test/acceptance/server.js +++ b/test/acceptance/server.js @@ -771,6 +771,42 @@ suite('server', function() { }); }); + // See https://github.com/CartoDB/Windshaft-cartodb/issues/88 + test("get'ing a tile from a user-specific database should return an expected tile", function(done){ + var style = querystring.stringify({style: test_style_black_200, style_version: '2.0.0'}); + var backupDBHost = global.environment.postgres.host; + global.environment.postgres.host = '6.6.6.6'; + Step ( + function() { + var next = this; + assert.response(server, { + headers: {host: 'cartodb250user'}, + url: '/tiles/test_table/15/16046/12354.png?cache_buster=4&' + style, // madrid + method: 'GET', + encoding: 'binary' + },{}, function(res){ + next(null, res); + }); + }, + function checkRes(err, res) { + assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); + var ct = res.headers['content-type']; + assert.equal(ct, 'image/png'); + assert.imageEqualsFile(res.body, + './test/fixtures/test_table_15_16046_12354_styled_black.png', + 2, this); + }, + function checkImage(err, similarity) { + if (err) throw err; + return null + }, + function finish(err) { + global.environment.postgres.host = backupDBHost; + done(err); + } + ); + }); + test("get'ing a tile with url specified 2.1.0 style should return an expected tile", function(done){ var style = querystring.stringify({style: test_style_black_210, style_version: '2.1.0'}); assert.response(server, { diff --git a/test/support/prepare_db.sh b/test/support/prepare_db.sh index 60696072..0468ceca 100755 --- a/test/support/prepare_db.sh +++ b/test/support/prepare_db.sh @@ -67,6 +67,13 @@ echo "HSET rails:users:localhost id ${TESTUSERID}" | redis-cli -p ${REDIS_PORT} echo 'HSET rails:users:localhost database_name "'"${TEST_DB}"'"' | redis-cli -p ${REDIS_PORT} -n 5 echo "HSET rails:users:localhost map_key 1234" | redis-cli -p ${REDIS_PORT} -n 5 echo "SADD rails:users:localhost:map_key 1235" | redis-cli -p ${REDIS_PORT} -n 5 + +# A user configured as with cartodb-2.5.0+ +echo "HSET rails:users:cartodb250user id ${TESTUSERID}" | redis-cli -p ${REDIS_PORT} -n 5 +echo 'HSET rails:users:cartodb250user database_name "'${TEST_DB}'"' | redis-cli -p ${REDIS_PORT} -n 5 +echo 'HSET rails:users:cartodb250user database_host "localhost"' | redis-cli -p ${REDIS_PORT} -n 5 +echo 'HSET rails:users:cartodb250user database_password "'${TESTPASS}'"' | 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 'HSET rails:'"${TEST_DB}"':test_table_private_1 privacy "0"' | redis-cli -p ${REDIS_PORT} -n 0