Windshaft-cartodb/test/integration/overviews-metadata-api.js

54 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-01-21 20:33:45 +08:00
require('../support/test_helper');
var assert = require('assert');
var RedisPool = require('redis-mpool');
var cartodbRedis = require('cartodb-redis');
var PgConnection = require('../../lib/cartodb/backends/pg_connection');
var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner');
var OverviewsMetadataBackend = require('../../lib/cartodb/backends/overviews-metadata');
2016-01-21 20:33:45 +08:00
describe('OverviewsMetadataBackend', function() {
2016-01-21 20:33:45 +08:00
var overviewsMetadataBackend;
2016-01-21 20:33:45 +08:00
before(function() {
var redisPool = new RedisPool(global.environment.redis);
var metadataBackend = cartodbRedis({pool: redisPool});
var pgConnection = new PgConnection(metadataBackend);
var pgQueryRunner = new PgQueryRunner(pgConnection);
overviewsMetadataBackend = new OverviewsMetadataBackend(pgQueryRunner);
2016-01-21 20:33:45 +08:00
});
it('should return an empty relation for tables that have no overviews', function(done) {
var query = 'select * from test_table';
overviewsMetadataBackend.getOverviewsMetadata('localhost', query, function(err, result) {
2016-01-21 20:33:45 +08:00
assert.ok(!err, err);
assert.deepEqual(result, {});
done();
});
});
it('should return overviews metadata', function(done) {
var query = 'select * from test_table_overviews';
overviewsMetadataBackend.getOverviewsMetadata('localhost', query, function(err, result) {
2016-01-21 20:33:45 +08:00
assert.ok(!err, err);
assert.deepEqual(result, {
'test_table_overviews': {
schema: 'public',
1: { table: '_vovw_1_test_table_overviews' },
2: { table: '_vovw_2_test_table_overviews' }
2016-01-21 20:33:45 +08:00
}
});
done();
});
});
});