-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
smoke-materialize.test.ts
77 lines (68 loc) · 2.12 KB
/
smoke-materialize.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { StartedTestContainer } from 'testcontainers';
import { MaterializeDBRunner } from '@cubejs-backend/testing-shared';
import cubejs, { CubeApi } from '@cubejs-client/core';
// eslint-disable-next-line import/no-extraneous-dependencies
import { afterAll, beforeAll, expect, jest } from '@jest/globals';
import { pausePromise } from '@cubejs-backend/shared';
import { BirdBox, getBirdbox } from '../src';
import {
DEFAULT_API_TOKEN,
DEFAULT_CONFIG,
JEST_AFTER_ALL_DEFAULT_TIMEOUT,
JEST_BEFORE_ALL_DEFAULT_TIMEOUT,
testQueryMeasure,
} from './smoke-tests';
describe('materialize', () => {
jest.setTimeout(60 * 5 * 1000);
let db: StartedTestContainer;
let birdbox: BirdBox;
let client: CubeApi;
beforeAll(async () => {
db = await MaterializeDBRunner.startContainer({});
birdbox = await getBirdbox(
'materialize',
{
CUBEJS_DB_TYPE: 'materialize',
CUBEJS_DB_HOST: db.getHost(),
CUBEJS_DB_PORT: `${db.getMappedPort(6875)}`,
CUBEJS_DB_NAME: 'materialize',
CUBEJS_DB_USER: 'materialize',
CUBEJS_DB_PASS: 'materialize',
CUBEJS_DB_SSL: 'false',
...DEFAULT_CONFIG,
},
{
schemaDir: 'materialize/schema',
}
);
client = cubejs(async () => DEFAULT_API_TOKEN, {
apiUrl: birdbox.configuration.apiUrl,
});
}, JEST_BEFORE_ALL_DEFAULT_TIMEOUT);
afterAll(async () => {
await birdbox.stop();
await db.stop();
}, JEST_AFTER_ALL_DEFAULT_TIMEOUT);
test('query measure', () => testQueryMeasure(client));
test('query dimensions', async () => {
const queryDimensions = async () => {
const response = await client.load({
measures: [
'Orders.totalAmount',
],
dimensions: [
'Orders.status',
],
});
expect(response.rawData()).toMatchSnapshot('dimensions');
};
await queryDimensions();
/**
* Running a query with 2 seconds delay
* preAggregation has 1 second in the refreshKey
* Gives times to trigger the action if hasn't been triggered yet.
*/
await pausePromise(2000);
await queryDimensions();
});
});