Add test with mapconfig's query against a table to ensure cache buster metrics are sent with the right values.

This commit is contained in:
Daniel García Aubert 2020-05-01 11:43:37 +02:00
parent 24863b6393
commit 05e77b2aed

View File

@ -18,12 +18,27 @@ const mapConfig = {
]
};
const mapConfigWithTable = {
version: '1.8.0',
layers: [
{
options: {
sql: 'select * from test_table',
cartocss: TestClient.CARTOCSS.POINTS,
cartocss_version: '2.3.0'
}
}
]
};
function templateBuilder ({ name }) {
const templateName = `metrics-template-${name}-${Date.now()}`;
return {
version: '0.0.1',
name: `metrics-template-${name}`,
name: templateName,
layergroup: {
stat_tag: `stat-tag-${name}`,
stat_tag: `stat-tag-${templateName}`,
version: '1.8.0',
layers: [
{
@ -37,9 +52,43 @@ function templateBuilder ({ name }) {
]
}
};
};
}
describe('metrics', function () {
function templateMissingCartoCSSVersionBuilder () {
const templateName = `missing-cartocss-version-${Date.now()}`;
return {
version: '0.0.1',
name: templateName,
layergroup: {
stat_tag: `stat-tag-${templateName}`,
version: '1.8.0',
layers: [
{
type: 'cartodb',
options: {
sql: TestClient.SQL.ONE_POINT,
cartocss: TestClient.CARTOCSS.POINTS
}
}
]
}
};
}
const suites = [
{
desc: 'map config with live query',
mapConfig
},
{
desc: 'map config with query against table',
mapConfig: mapConfigWithTable
}
];
suites.forEach(function ({ desc, mapConfig }) {
describe(`metrics: ${desc}`, function () {
beforeEach(function () {
this.originalMetricsBackendSendMethod = MetricsBackend.prototype.send;
this.pubSubMetricsBackendSendMethodCalled = false;
@ -366,24 +415,7 @@ describe('metrics', function () {
'Carto-Event-Group-Id': expectedEventGroupId
};
const overrideServerOptions = { pubSubMetrics: { enabled: true, topic: 'topic-test' } };
const templateMissingCartoCSSVersion = {
version: '0.0.1',
name: 'metrics-template-missing-cartocss-version',
layergroup: {
stat_tag: 'stat-tag-missing-cartocss-version',
version: '1.8.0',
layers: [
{
type: 'cartodb',
options: {
sql: TestClient.SQL.ONE_POINT,
cartocss: TestClient.CARTOCSS.POINTS
}
}
]
}
};
const templateMissingCartoCSSVersion = templateMissingCartoCSSVersionBuilder();
this.testClient = new TestClient(templateMissingCartoCSSVersion, apikey, extraHeaders, overrideServerOptions);
const params = {
@ -547,4 +579,5 @@ describe('metrics', function () {
return done();
});
});
});
});