@cubejs-backend/testing-shared 0.29.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +16 -0
  4. package/dist/src/DriverTests.d.ts +25 -0
  5. package/dist/src/DriverTests.d.ts.map +1 -0
  6. package/dist/src/DriverTests.js +99 -0
  7. package/dist/src/DriverTests.js.map +1 -0
  8. package/dist/src/db/cubestore.d.ts +9 -0
  9. package/dist/src/db/cubestore.d.ts.map +1 -0
  10. package/dist/src/db/cubestore.js +22 -0
  11. package/dist/src/db/cubestore.js.map +1 -0
  12. package/dist/src/db/db-runner.abstract.d.ts +11 -0
  13. package/dist/src/db/db-runner.abstract.d.ts.map +1 -0
  14. package/dist/src/db/db-runner.abstract.js +8 -0
  15. package/dist/src/db/db-runner.abstract.js.map +1 -0
  16. package/dist/src/db/index.d.ts +5 -0
  17. package/dist/src/db/index.d.ts.map +1 -0
  18. package/dist/src/db/index.js +17 -0
  19. package/dist/src/db/index.js.map +1 -0
  20. package/dist/src/db/mysql.d.ts +9 -0
  21. package/dist/src/db/mysql.d.ts.map +1 -0
  22. package/dist/src/db/mysql.js +37 -0
  23. package/dist/src/db/mysql.js.map +1 -0
  24. package/dist/src/db/postgres.d.ts +9 -0
  25. package/dist/src/db/postgres.d.ts.map +1 -0
  26. package/dist/src/db/postgres.js +33 -0
  27. package/dist/src/db/postgres.js.map +1 -0
  28. package/dist/src/db/questdb.d.ts +9 -0
  29. package/dist/src/db/questdb.d.ts.map +1 -0
  30. package/dist/src/db/questdb.js +22 -0
  31. package/dist/src/db/questdb.js.map +1 -0
  32. package/dist/src/index.d.ts +5 -0
  33. package/dist/src/index.d.ts.map +1 -0
  34. package/dist/src/index.js +17 -0
  35. package/dist/src/index.js.map +1 -0
  36. package/dist/src/query-test.abstract.d.ts +25 -0
  37. package/dist/src/query-test.abstract.d.ts.map +1 -0
  38. package/dist/src/query-test.abstract.js +121 -0
  39. package/dist/src/query-test.abstract.js.map +1 -0
  40. package/dist/src/utils.d.ts +9 -0
  41. package/dist/src/utils.d.ts.map +1 -0
  42. package/dist/src/utils.js +61 -0
  43. package/dist/src/utils.js.map +1 -0
  44. package/package.json +56 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [0.29.33](https://github.com/cube-js/cube.js/compare/v0.29.32...v0.29.33) (2022-03-17)
7
+
8
+ **Note:** Version bump only for package @cubejs-backend/testing-shared
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Cube Dev, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ <p align="center"><a href="https://cube.dev"><img src="https://i.imgur.com/zYHXm4o.png" alt="Cube.js" width="300px"></a></p>
2
+
3
+ [Website](https://cube.dev) • [Docs](https://cube.dev/docs) • [Blog](https://cube.dev/blog) • [Slack](https://slack.cube.dev) • [Discourse](https://forum.cube.dev/) • [Twitter](https://twitter.com/thecubejs)
4
+
5
+ [![npm version](https://badge.fury.io/js/%40cubejs-backend%2Fserver.svg)](https://badge.fury.io/js/%40cubejs-backend%2Fserver)
6
+ [![GitHub Actions](https://github.com/cube-js/cube.js/workflows/Build/badge.svg)](https://github.com/cube-js/cube.js/actions?query=workflow%3ABuild+branch%3Amaster)
7
+
8
+ # Cube.js Testing
9
+
10
+ Internal package for testing.
11
+
12
+ [Learn more](https://github.com/cube-js/cube.js#getting-started)
13
+
14
+ ### License
15
+
16
+ Cube.js Client Core is [MIT licensed](./LICENSE).
@@ -0,0 +1,25 @@
1
+ import { DriverInterface } from '@cubejs-backend/query-orchestrator';
2
+ export interface DriverTestsOptions {
3
+ expectStringFields?: boolean;
4
+ csvNoHeader?: boolean;
5
+ wrapLoadQueryWithCtas?: boolean;
6
+ }
7
+ export declare class DriverTests {
8
+ readonly driver: DriverInterface;
9
+ private readonly options;
10
+ constructor(driver: DriverInterface, options?: DriverTestsOptions);
11
+ release(): Promise<void>;
12
+ static QUERY: string;
13
+ static ROWS: {
14
+ id: number;
15
+ amount: number;
16
+ status: string;
17
+ }[];
18
+ static CSV_ROWS: string;
19
+ testQuery(): Promise<void>;
20
+ testStream(): Promise<void>;
21
+ testUnload(): Promise<void>;
22
+ private skipFirstLine;
23
+ private rowsToString;
24
+ }
25
+ //# sourceMappingURL=DriverTests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DriverTests.d.ts","sourceRoot":"","sources":["../../src/DriverTests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAmB,MAAM,oCAAoC,CAAC;AAMtF,MAAM,WAAW,kBAAkB;IAEjC,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAG5B,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED,qBAAa,WAAW;aAEJ,MAAM,EAAE,eAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADR,MAAM,EAAE,eAAe,EACtB,OAAO,GAAE,kBAAuB;IAI5C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,OAAc,KAAK,SAUjB;IAEF,OAAc,IAAI;;;;QAIhB;IAEF,OAAc,QAAQ,SAIpB;IAEW,SAAS;IAMT,UAAU;IASV,UAAU;IAmCvB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;CAWrB"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DriverTests = void 0;
7
+ const query_orchestrator_1 = require("@cubejs-backend/query-orchestrator");
8
+ const shared_1 = require("@cubejs-backend/shared");
9
+ const crypto_1 = __importDefault(require("crypto"));
10
+ const dedent_1 = __importDefault(require("dedent"));
11
+ const stream_1 = require("stream");
12
+ class DriverTests {
13
+ constructor(driver, options = {}) {
14
+ this.driver = driver;
15
+ this.options = options;
16
+ }
17
+ release() {
18
+ return this.driver.release();
19
+ }
20
+ async testQuery() {
21
+ const rows = await this.driver.query(DriverTests.QUERY, []);
22
+ const expectedRows = this.options.expectStringFields ? this.rowsToString(DriverTests.ROWS) : DriverTests.ROWS;
23
+ expect(rows).toEqual(expectedRows);
24
+ }
25
+ async testStream() {
26
+ expect(this.driver.stream).toBeDefined();
27
+ const tableData = await this.driver.stream(DriverTests.QUERY, [], { highWaterMark: 100 });
28
+ expect(tableData.rowStream instanceof stream_1.Readable);
29
+ const rows = await shared_1.streamToArray(tableData.rowStream);
30
+ const expectedRows = this.options.expectStringFields ? this.rowsToString(DriverTests.ROWS) : DriverTests.ROWS;
31
+ expect(rows).toEqual(expectedRows);
32
+ }
33
+ async testUnload() {
34
+ expect(this.driver.unload).toBeDefined();
35
+ const versionEntry = {
36
+ table_name: 'test.orders_order_status',
37
+ structure_version: crypto_1.default.randomBytes(10).toString('hex'),
38
+ content_version: crypto_1.default.randomBytes(10).toString('hex'),
39
+ last_updated_at: new Date().getTime(),
40
+ naming_version: 2
41
+ };
42
+ const tableName = query_orchestrator_1.PreAggregations.targetTableName(versionEntry);
43
+ const query = `
44
+ SELECT orders.status AS orders__status, sum(orders.amount) AS orders__amount
45
+ FROM (${DriverTests.QUERY}) AS orders
46
+ GROUP BY 1
47
+ ORDER BY 1
48
+ `;
49
+ const loadQuery = this.options.wrapLoadQueryWithCtas ? `CREATE TABLE ${tableName} AS ${query}` : query;
50
+ await this.driver.loadPreAggregationIntoTable(tableName, loadQuery, [], {
51
+ newVersionEntry: versionEntry,
52
+ targetTableName: tableName,
53
+ });
54
+ const data = await this.driver.unload(tableName, { maxFileSize: 64 });
55
+ expect(data.csvFile.length).toEqual(1);
56
+ const string = await shared_1.downloadAndGunzip(data.csvFile[0]);
57
+ const expectedRows = this.options.csvNoHeader
58
+ ? this.skipFirstLine(DriverTests.CSV_ROWS)
59
+ : DriverTests.CSV_ROWS;
60
+ expect(string.trim()).toEqual(expectedRows);
61
+ }
62
+ skipFirstLine(text) {
63
+ return text.split('\n').slice(1).join('\n');
64
+ }
65
+ rowsToString(rows) {
66
+ const result = [];
67
+ for (const row of rows) {
68
+ const newRow = {};
69
+ for (const k of Object.keys(row)) {
70
+ newRow[k] = row[k].toString();
71
+ }
72
+ result.push(newRow);
73
+ }
74
+ return result;
75
+ }
76
+ }
77
+ exports.DriverTests = DriverTests;
78
+ DriverTests.QUERY = `
79
+ SELECT id, amount, status
80
+ FROM (
81
+ SELECT 1 AS id, 100 AS amount, 'new' AS status
82
+ UNION ALL
83
+ SELECT 2 AS id, 200 AS amount, 'new' AS status
84
+ UNION ALL
85
+ SELECT 3 AS id, 400 AS amount, 'processed' AS status
86
+ )
87
+ ORDER BY 1
88
+ `;
89
+ DriverTests.ROWS = [
90
+ { id: 1, amount: 100, status: 'new' },
91
+ { id: 2, amount: 200, status: 'new' },
92
+ { id: 3, amount: 400, status: 'processed' },
93
+ ];
94
+ DriverTests.CSV_ROWS = dedent_1.default `
95
+ orders__status,orders__amount
96
+ new,300
97
+ processed,400
98
+ `;
99
+ //# sourceMappingURL=DriverTests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DriverTests.js","sourceRoot":"","sources":["../../src/DriverTests.ts"],"names":[],"mappings":";;;;;;AAAA,2EAAsF;AACtF,mDAA0E;AAC1E,oDAA4B;AAC5B,oDAA4B;AAC5B,mCAAkC;AAYlC,MAAa,WAAW;IACtB,YACkB,MAAuB,EACtB,UAA8B,EAAE;QADjC,WAAM,GAAN,MAAM,CAAiB;QACtB,YAAO,GAAP,OAAO,CAAyB;IAEnD,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IA0BM,KAAK,CAAC,SAAS;QACpB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5D,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QAC9G,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAO,CAAC,WAAW,CAAC,KAAK,EAAE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AI,GAAG;IACnB,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE;IACrC,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE;IACrC,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE;CAC5C,CAAC;AAEY,oBAAQ,GAAG,gBAAM,CAAA;;;;GAI9B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { DbRunnerAbstract, DBRunnerContainerOptions } from './db-runner.abstract';
2
+ declare type CubeStoreStartOptions = DBRunnerContainerOptions & {
3
+ version?: string;
4
+ };
5
+ export declare class CubeStoreDBRunner extends DbRunnerAbstract {
6
+ static startContainer(options: CubeStoreStartOptions): Promise<import("testcontainers").StartedTestContainer>;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=cubestore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cubestore.d.ts","sourceRoot":"","sources":["../../../src/db/cubestore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAElF,aAAK,qBAAqB,GAAG,wBAAwB,GAAG;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,gBAAgB;WACvC,cAAc,CAAC,OAAO,EAAE,qBAAqB;CAgB5D"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CubeStoreDBRunner = void 0;
4
+ const testcontainers_1 = require("testcontainers");
5
+ const db_runner_abstract_1 = require("./db-runner.abstract");
6
+ class CubeStoreDBRunner extends db_runner_abstract_1.DbRunnerAbstract {
7
+ static startContainer(options) {
8
+ const version = process.env.TEST_CUBESTORE_VERSION || options.version || 'latest';
9
+ const builder = new testcontainers_1.GenericContainer(`cubejs/cubestore:${version}`)
10
+ .withStartupTimeout(10 * 1000)
11
+ .withExposedPorts(3030);
12
+ if (options.volumes) {
13
+ // eslint-disable-next-line no-restricted-syntax
14
+ for (const { source, target, bindMode } of options.volumes) {
15
+ builder.withBindMount(source, target, bindMode);
16
+ }
17
+ }
18
+ return builder.start();
19
+ }
20
+ }
21
+ exports.CubeStoreDBRunner = CubeStoreDBRunner;
22
+ //# sourceMappingURL=cubestore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cubestore.js","sourceRoot":"","sources":["../../../src/db/cubestore.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAElD,6DAAkF;AAMlF,MAAa,iBAAkB,SAAQ,qCAAgB;IAC9C,MAAM,CAAC,cAAc,CAAC,OAA8B;QACzD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC;QAElF,MAAM,OAAO,GAAG,IAAI,iCAAgB,CAAC,oBAAoB,OAAO,EAAE,CAAC;aAChE,kBAAkB,CAAC,EAAE,GAAG,IAAI,CAAC;aAC7B,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAE1B,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,gDAAgD;YAChD,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;gBAC1D,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;aACjD;SACF;QAED,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF;AAjBD,8CAiBC"}
@@ -0,0 +1,11 @@
1
+ export interface ContainerVolumeDefinition {
2
+ source: string;
3
+ target: string;
4
+ bindMode?: 'rw' | 'ro';
5
+ }
6
+ export interface DBRunnerContainerOptions {
7
+ volumes?: ContainerVolumeDefinition[];
8
+ }
9
+ export declare abstract class DbRunnerAbstract {
10
+ }
11
+ //# sourceMappingURL=db-runner.abstract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-runner.abstract.d.ts","sourceRoot":"","sources":["../../../src/db/db-runner.abstract.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,yBAAyB,EAAE,CAAA;CACtC;AAGD,8BAAsB,gBAAgB;CAErC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DbRunnerAbstract = void 0;
4
+ // @todo Finish with old one PR for it
5
+ class DbRunnerAbstract {
6
+ }
7
+ exports.DbRunnerAbstract = DbRunnerAbstract;
8
+ //# sourceMappingURL=db-runner.abstract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-runner.abstract.js","sourceRoot":"","sources":["../../../src/db/db-runner.abstract.ts"],"names":[],"mappings":";;;AAUA,sCAAsC;AACtC,MAAsB,gBAAgB;CAErC;AAFD,4CAEC"}
@@ -0,0 +1,5 @@
1
+ export * from './mysql';
2
+ export * from './postgres';
3
+ export * from './cubestore';
4
+ export * from './questdb';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./mysql"), exports);
14
+ __exportStar(require("./postgres"), exports);
15
+ __exportStar(require("./cubestore"), exports);
16
+ __exportStar(require("./questdb"), exports);
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B;AAC3B,8CAA4B;AAC5B,4CAA0B"}
@@ -0,0 +1,9 @@
1
+ import { DbRunnerAbstract, DBRunnerContainerOptions } from './db-runner.abstract';
2
+ declare type MySQLStartOptions = DBRunnerContainerOptions & {
3
+ version?: string;
4
+ };
5
+ export declare class MysqlDBRunner extends DbRunnerAbstract {
6
+ static startContainer(options: MySQLStartOptions): Promise<import("testcontainers").StartedTestContainer>;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=mysql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../../../src/db/mysql.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAElF,aAAK,iBAAiB,GAAG,wBAAwB,GAAG;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,aAAc,SAAQ,gBAAgB;WACnC,cAAc,CAAC,OAAO,EAAE,iBAAiB;CAgCxD"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MysqlDBRunner = void 0;
4
+ const testcontainers_1 = require("testcontainers");
5
+ const db_runner_abstract_1 = require("./db-runner.abstract");
6
+ class MysqlDBRunner extends db_runner_abstract_1.DbRunnerAbstract {
7
+ static startContainer(options) {
8
+ const version = process.env.TEST_MYSQL_VERSION || options.version || '5.7';
9
+ const builder = new testcontainers_1.GenericContainer(`mysql:${version}`)
10
+ .withEnv('MYSQL_ROOT_PASSWORD', process.env.TEST_DB_PASSWORD || 'Test1test')
11
+ .withHealthCheck({
12
+ test: 'mysqladmin ping -h localhost',
13
+ interval: 5 * 1000,
14
+ timeout: 2 * 1000,
15
+ retries: 3,
16
+ startPeriod: 10 * 1000,
17
+ })
18
+ .withWaitStrategy(testcontainers_1.Wait.forHealthCheck())
19
+ .withExposedPorts(3306);
20
+ if (version.split('.')[0] === '8') {
21
+ /**
22
+ * workaround for MySQL 8 and unsupported auth in mysql package
23
+ * @link https://github.com/mysqljs/mysql/pull/2233
24
+ */
25
+ builder.withCmd(['--default-authentication-plugin=mysql_native_password']);
26
+ }
27
+ if (options.volumes) {
28
+ // eslint-disable-next-line no-restricted-syntax
29
+ for (const { source, target, bindMode } of options.volumes) {
30
+ builder.withBindMount(source, target, bindMode);
31
+ }
32
+ }
33
+ return builder.start();
34
+ }
35
+ }
36
+ exports.MysqlDBRunner = MysqlDBRunner;
37
+ //# sourceMappingURL=mysql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.js","sourceRoot":"","sources":["../../../src/db/mysql.ts"],"names":[],"mappings":";;;AAAA,mDAAwD;AAExD,6DAAkF;AAMlF,MAAa,aAAc,SAAQ,qCAAgB;IAC1C,MAAM,CAAC,cAAc,CAAC,OAA0B;QACrD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;QAE3E,MAAM,OAAO,GAAG,IAAI,iCAAgB,CAAC,SAAS,OAAO,EAAE,CAAC;aACrD,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,WAAW,CAAC;aAC3E,eAAe,CAAC;YACf,IAAI,EAAE,8BAA8B;YACpC,QAAQ,EAAE,CAAC,GAAG,IAAI;YAClB,OAAO,EAAE,CAAC,GAAG,IAAI;YACjB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,EAAE,GAAG,IAAI;SACvB,CAAC;aACD,gBAAgB,CAAC,qBAAI,CAAC,cAAc,EAAE,CAAC;aACvC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAE1B,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YACjC;;;eAGG;YACH,OAAO,CAAC,OAAO,CAAC,CAAC,uDAAuD,CAAC,CAAC,CAAC;SAC5E;QAED,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,gDAAgD;YAChD,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;gBAC1D,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;aACjD;SACF;QAED,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF;AAjCD,sCAiCC"}
@@ -0,0 +1,9 @@
1
+ import { DbRunnerAbstract, DBRunnerContainerOptions } from './db-runner.abstract';
2
+ declare type PostgresStartOptions = DBRunnerContainerOptions & {
3
+ version?: string;
4
+ };
5
+ export declare class PostgresDBRunner extends DbRunnerAbstract {
6
+ static startContainer(options: PostgresStartOptions): Promise<import("testcontainers").StartedTestContainer>;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=postgres.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../src/db/postgres.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAElF,aAAK,oBAAoB,GAAG,wBAAwB,GAAG;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,gBAAgB;WACtC,cAAc,CAAC,OAAO,EAAE,oBAAoB;CA2B3D"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostgresDBRunner = void 0;
4
+ const testcontainers_1 = require("testcontainers");
5
+ const db_runner_abstract_1 = require("./db-runner.abstract");
6
+ class PostgresDBRunner extends db_runner_abstract_1.DbRunnerAbstract {
7
+ static startContainer(options) {
8
+ const version = process.env.TEST_PGSQL_VERSION || options.version || '9.6.8';
9
+ const container = new testcontainers_1.GenericContainer(`postgres:${version}`)
10
+ .withEnv('POSTGRES_USER', 'test')
11
+ .withEnv('POSTGRES_DB', 'test')
12
+ .withEnv('POSTGRES_PASSWORD', 'test')
13
+ .withExposedPorts(5432)
14
+ // .withHealthCheck({
15
+ // test: 'pg_isready -U root -d model_test',
16
+ // interval: 2 * 1000,
17
+ // timeout: 500,
18
+ // retries: 3
19
+ // })
20
+ // .withWaitStrategy(Wait.forHealthCheck())
21
+ // Postgresql do fast shutdown on start for db applying
22
+ .withStartupTimeout(10 * 1000);
23
+ if (options.volumes) {
24
+ // eslint-disable-next-line no-restricted-syntax
25
+ for (const { source, target, bindMode } of options.volumes) {
26
+ container.withBindMount(source, target, bindMode);
27
+ }
28
+ }
29
+ return container.start();
30
+ }
31
+ }
32
+ exports.PostgresDBRunner = PostgresDBRunner;
33
+ //# sourceMappingURL=postgres.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../../src/db/postgres.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAElD,6DAAkF;AAMlF,MAAa,gBAAiB,SAAQ,qCAAgB;IAC7C,MAAM,CAAC,cAAc,CAAC,OAA6B;QACxD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC;QAE7E,MAAM,SAAS,GAAG,IAAI,iCAAgB,CAAC,YAAY,OAAO,EAAE,CAAC;aAC1D,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC;aAChC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC;aAC9B,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;aACpC,gBAAgB,CAAC,IAAI,CAAC;YACvB,qBAAqB;YACrB,8CAA8C;YAC9C,wBAAwB;YACxB,kBAAkB;YAClB,eAAe;YACf,KAAK;YACL,2CAA2C;YAC3C,uDAAuD;aACtD,kBAAkB,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;QAEjC,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,gDAAgD;YAChD,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;gBAC1D,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;aACnD;SACF;QAED,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF;AA5BD,4CA4BC"}
@@ -0,0 +1,9 @@
1
+ import { DbRunnerAbstract, DBRunnerContainerOptions } from './db-runner.abstract';
2
+ declare type QuestStartOptions = DBRunnerContainerOptions & {
3
+ version?: string;
4
+ };
5
+ export declare class QuestDBRunner extends DbRunnerAbstract {
6
+ static startContainer(options: QuestStartOptions): Promise<import("testcontainers").StartedTestContainer>;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=questdb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questdb.d.ts","sourceRoot":"","sources":["../../../src/db/questdb.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAElF,aAAK,iBAAiB,GAAG,wBAAwB,GAAG;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,aAAc,SAAQ,gBAAgB;WACnC,cAAc,CAAC,OAAO,EAAE,iBAAiB;CAgBxD"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestDBRunner = void 0;
4
+ const testcontainers_1 = require("testcontainers");
5
+ const db_runner_abstract_1 = require("./db-runner.abstract");
6
+ class QuestDBRunner extends db_runner_abstract_1.DbRunnerAbstract {
7
+ static startContainer(options) {
8
+ const version = process.env.TEST_QUEST_DB_VERSION || options.version || '6.2.1';
9
+ const container = new testcontainers_1.GenericContainer(`questdb/questdb:${version}`)
10
+ .withExposedPorts(8812)
11
+ .withStartupTimeout(10 * 1000);
12
+ if (options.volumes) {
13
+ // eslint-disable-next-line no-restricted-syntax
14
+ for (const { source, target, bindMode } of options.volumes) {
15
+ container.withBindMount(source, target, bindMode);
16
+ }
17
+ }
18
+ return container.start();
19
+ }
20
+ }
21
+ exports.QuestDBRunner = QuestDBRunner;
22
+ //# sourceMappingURL=questdb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questdb.js","sourceRoot":"","sources":["../../../src/db/questdb.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAElD,6DAAkF;AAMlF,MAAa,aAAc,SAAQ,qCAAgB;IAC1C,MAAM,CAAC,cAAc,CAAC,OAA0B;QACrD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC;QAEhF,MAAM,SAAS,GAAG,IAAI,iCAAgB,CAAC,mBAAmB,OAAO,EAAE,CAAC;aACjE,gBAAgB,CAAC,IAAI,CAAC;aACtB,kBAAkB,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;QAEjC,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,gDAAgD;YAChD,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;gBAC1D,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;aACnD;SACF;QAED,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF;AAjBD,sCAiBC"}
@@ -0,0 +1,5 @@
1
+ export * from './query-test.abstract';
2
+ export * from './DriverTests';
3
+ export * from './utils';
4
+ export * from './db';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AAExB,cAAc,MAAM,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./query-test.abstract"), exports);
14
+ __exportStar(require("./DriverTests"), exports);
15
+ __exportStar(require("./utils"), exports);
16
+ __exportStar(require("./db"), exports);
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAsC;AACtC,gDAA8B;AAC9B,0CAAwB;AAExB,uCAAqB"}
@@ -0,0 +1,25 @@
1
+ import { BaseDriver } from '@cubejs-backend/query-orchestrator';
2
+ import { BaseQuery } from '@cubejs-backend/schema-compiler';
3
+ import { StartedTestContainer } from 'testcontainers';
4
+ export declare const prepareCompiler: (content: any, options?: any) => {
5
+ compiler: import("@cubejs-backend/schema-compiler/dist/src/compiler/DataSchemaCompiler").DataSchemaCompiler;
6
+ metaTransformer: import("@cubejs-backend/schema-compiler/dist/src/compiler/CubeToMetaTransformer").CubeToMetaTransformer;
7
+ cubeEvaluator: import("@cubejs-backend/schema-compiler/dist/src/compiler/CubeEvaluator").CubeEvaluator;
8
+ contextEvaluator: import("@cubejs-backend/schema-compiler/dist/src/compiler/ContextEvaluator").ContextEvaluator;
9
+ joinGraph: import("@cubejs-backend/schema-compiler/dist/src/compiler/JoinGraph").JoinGraph;
10
+ compilerCache: import("@cubejs-backend/schema-compiler/dist/src/compiler/CompilerCache").CompilerCache;
11
+ headCommitId: any;
12
+ };
13
+ export declare abstract class QueryTestAbstract<T extends BaseDriver> {
14
+ abstract getQueryClass(): any;
15
+ protected getQuery(a: any, b: any): BaseQuery;
16
+ testRefreshKeyEveryDay(connection: T): Promise<void>;
17
+ testRefreshKeyIncrementalWithUpdateWindow(connection: T): Promise<void>;
18
+ }
19
+ export interface QueryTestCaseOptions {
20
+ name: string;
21
+ connectionFactory: (container: StartedTestContainer) => BaseDriver;
22
+ DbRunnerClass: any;
23
+ }
24
+ export declare function createQueryTestCase(test: QueryTestAbstract<any>, opts: QueryTestCaseOptions): void;
25
+ //# sourceMappingURL=query-test.abstract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-test.abstract.d.ts","sourceRoot":"","sources":["../../src/query-test.abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,SAAS,EAA8C,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAKtD,eAAO,MAAM,eAAe,YAAa,GAAG,YAAY,GAAG;;;;;;;;CAKpB,CAAC;AAExC,8BAAsB,iBAAiB,CAAC,CAAC,SAAS,UAAU;IAC1D,QAAQ,CAAC,aAAa,IAAI,GAAG;IAE7B,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,SAAS;IAMhC,sBAAsB,CAAC,UAAU,EAAE,CAAC;IA4CpC,yCAAyC,CAAC,UAAU,EAAE,CAAC;CAiDrE;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,CAAC,SAAS,EAAE,oBAAoB,KAAK,UAAU,CAAC;IACnE,aAAa,EAAE,GAAG,CAAC;CACpB;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,oBAAoB,QAyB3F"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createQueryTestCase = exports.QueryTestAbstract = exports.prepareCompiler = void 0;
4
+ const schema_compiler_1 = require("@cubejs-backend/schema-compiler");
5
+ const shared_1 = require("@cubejs-backend/shared");
6
+ const utils_1 = require("./utils");
7
+ const prepareCompiler = (content, options) => schema_compiler_1.prepareCompiler({
8
+ localPath: () => __dirname,
9
+ dataSchemaFiles: () => Promise.resolve([
10
+ { fileName: 'main.js', content }
11
+ ])
12
+ }, { adapter: 'postgres', ...options });
13
+ exports.prepareCompiler = prepareCompiler;
14
+ class QueryTestAbstract {
15
+ getQuery(a, b) {
16
+ const QueryClass = this.getQueryClass();
17
+ return new QueryClass(a, b);
18
+ }
19
+ async testRefreshKeyEveryDay(connection) {
20
+ const { compiler, joinGraph, cubeEvaluator } = exports.prepareCompiler(utils_1.createCubeSchema({
21
+ name: 'cards',
22
+ preAggregations: `
23
+ countCreatedAt: {
24
+ type: 'rollup',
25
+ external: true,
26
+ measureReferences: [count],
27
+ timeDimensionReference: createdAt,
28
+ granularity: \`day\`,
29
+ partitionGranularity: \`month\`,
30
+ scheduledRefresh: true,
31
+ refreshKey: {
32
+ every: \`1 day\`,
33
+ },
34
+ },
35
+ `
36
+ }));
37
+ await compiler.compile();
38
+ const query = this.getQuery({ joinGraph, cubeEvaluator, compiler }, {
39
+ measures: [
40
+ 'cards.count'
41
+ ],
42
+ timeDimensions: [{
43
+ dimension: 'cards.createdAt',
44
+ granularity: 'day',
45
+ dateRange: ['2016-12-30', '2017-01-05']
46
+ }],
47
+ filters: [],
48
+ timezone: 'America/Los_Angeles',
49
+ });
50
+ const preAggregations = query.newPreAggregations().preAggregationsDescription();
51
+ const [sql, params] = preAggregations[0].invalidateKeyQueries[0];
52
+ console.log('Executing ', [sql, params]);
53
+ await connection.query(sql, params, {});
54
+ }
55
+ async testRefreshKeyIncrementalWithUpdateWindow(connection) {
56
+ const { compiler, joinGraph, cubeEvaluator } = exports.prepareCompiler(utils_1.createCubeSchema({
57
+ name: 'cards',
58
+ preAggregations: `
59
+ countCreatedAt: {
60
+ type: 'rollup',
61
+ external: true,
62
+ measureReferences: [count],
63
+ timeDimensionReference: createdAt,
64
+ granularity: \`day\`,
65
+ partitionGranularity: \`month\`,
66
+ scheduledRefresh: true,
67
+ refreshKey: {
68
+ every: \`1 day\`,
69
+ incremental: true,
70
+ updateWindow: \`7 day\`,
71
+ },
72
+ },
73
+ `
74
+ }));
75
+ await compiler.compile();
76
+ const query = this.getQuery({ joinGraph, cubeEvaluator, compiler }, {
77
+ measures: [
78
+ 'cards.count'
79
+ ],
80
+ timeDimensions: [{
81
+ dimension: 'cards.createdAt',
82
+ granularity: 'day',
83
+ dateRange: ['2016-12-30', '2017-01-05']
84
+ }],
85
+ filters: [],
86
+ timezone: 'America/Los_Angeles',
87
+ });
88
+ const preAggregations = query.newPreAggregations().preAggregationsDescription();
89
+ // eslint-disable-next-line prefer-const
90
+ let [sql, params] = preAggregations[0].invalidateKeyQueries[0];
91
+ // TODO Introduce full cycle testing through BaseDbRunner / QueryOrchestrator.
92
+ // TODO Internal structures shouldn't be never accessed in tests.
93
+ params = params.map((p) => (p === shared_1.TO_PARTITION_RANGE ? '2017-01-05T00:00:00' : p));
94
+ console.log('Executing ', [sql, params]);
95
+ await connection.query(sql, params, {});
96
+ }
97
+ }
98
+ exports.QueryTestAbstract = QueryTestAbstract;
99
+ function createQueryTestCase(test, opts) {
100
+ describe(`${opts.name}Query`, () => {
101
+ jest.setTimeout(60 * 1000);
102
+ let container;
103
+ let connection;
104
+ beforeAll(async () => {
105
+ container = await opts.DbRunnerClass.startContainer({});
106
+ connection = opts.connectionFactory(container);
107
+ });
108
+ afterAll(async () => {
109
+ if (connection) {
110
+ await connection.release();
111
+ }
112
+ if (container) {
113
+ await container.stop();
114
+ }
115
+ });
116
+ it('test refreshKey every day', async () => test.testRefreshKeyEveryDay(connection));
117
+ it('test refreshKey incremental with update window', async () => test.testRefreshKeyIncrementalWithUpdateWindow(connection));
118
+ });
119
+ }
120
+ exports.createQueryTestCase = createQueryTestCase;
121
+ //# sourceMappingURL=query-test.abstract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-test.abstract.js","sourceRoot":"","sources":["../../src/query-test.abstract.ts"],"names":[],"mappings":";;;AACA,qEAAwG;AAExG,mDAA4D;AAE5D,mCAA2C;AAEpC,MAAM,eAAe,GAAG,CAAC,OAAY,EAAE,OAAa,EAAE,EAAE,CAAC,iCAAuB,CAAC;IACtF,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;IAC1B,eAAe,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;QACrC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE;KACjC,CAAC;CACH,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AAL3B,QAAA,eAAe,mBAKY;AAExC,MAAsB,iBAAiB;IAG3B,QAAQ,CAAC,CAAM,EAAE,CAAM;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAExC,OAAO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AAC,KAAK,IAAI,EAAE;YACnB,SAAS,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;YACxD,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,KAAK,IAAI,EAAE;YAClB,IAAI,UAAU,EAAE;gBACd,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;aAC5B;YAED,IAAI,SAAS,EAAE;gBACb,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;aACxB;QACH,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,CAAC;QACrF,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,yCAAyC,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/H,CAAC,CAAC,CAAC;AACL,CAAC;AAzBD,kDAyBC"}
@@ -0,0 +1,9 @@
1
+ export declare function getLocalHostnameByOs(): "docker.for.win.localhost" | "host.docker.internal" | "localhost";
2
+ interface CreateCubeSchemaOptions {
3
+ name: string;
4
+ refreshKey?: string;
5
+ preAggregations?: string;
6
+ }
7
+ export declare function createCubeSchema({ name, refreshKey, preAggregations }: CreateCubeSchemaOptions): string;
8
+ export {};
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,oBAAoB,sEAUnC;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,UAAe,EAAE,eAAoB,EAAE,EAAE,uBAAuB,UA4CxG"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCubeSchema = exports.getLocalHostnameByOs = void 0;
4
+ const os_1 = require("os");
5
+ function getLocalHostnameByOs() {
6
+ if (os_1.platform() === 'win32') {
7
+ return 'docker.for.win.localhost';
8
+ }
9
+ if (os_1.platform() === 'darwin') {
10
+ return 'host.docker.internal';
11
+ }
12
+ return 'localhost';
13
+ }
14
+ exports.getLocalHostnameByOs = getLocalHostnameByOs;
15
+ function createCubeSchema({ name, refreshKey = '', preAggregations = '' }) {
16
+ return `
17
+ cube('${name}', {
18
+ sql: \`
19
+ select * from cards
20
+ \`,
21
+
22
+ ${refreshKey}
23
+
24
+ measures: {
25
+ count: {
26
+ type: 'count'
27
+ },
28
+ sum: {
29
+ sql: \`amount\`,
30
+ type: \`sum\`
31
+ },
32
+ max: {
33
+ sql: \`amount\`,
34
+ type: \`max\`
35
+ },
36
+ min: {
37
+ sql: \`amount\`,
38
+ type: \`min\`
39
+ }
40
+ },
41
+
42
+ dimensions: {
43
+ id: {
44
+ type: 'number',
45
+ sql: 'id',
46
+ primaryKey: true
47
+ },
48
+ createdAt: {
49
+ type: 'time',
50
+ sql: 'created_at'
51
+ },
52
+ },
53
+
54
+ preAggregations: {
55
+ ${preAggregations}
56
+ }
57
+ })
58
+ `;
59
+ }
60
+ exports.createCubeSchema = createCubeSchema;
61
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA,2BAA8B;AAE9B,SAAgB,oBAAoB;IAClC,IAAI,aAAQ,EAAE,KAAK,OAAO,EAAE;QAC1B,OAAO,0BAA0B,CAAC;KACnC;IAED,IAAI,aAAQ,EAAE,KAAK,QAAQ,EAAE;QAC3B,OAAO,sBAAsB,CAAC;KAC/B;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAVD,oDAUC;AAQD,SAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,UAAU,GAAG,EAAE,EAAE,eAAe,GAAG,EAAE,EAA2B;IACvG,OAAO;YACG,IAAI;;;;;UAKN,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCN,eAAe;;;GAG1B,CAAC;AACJ,CAAC;AA5CD,4CA4CC"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@cubejs-backend/testing-shared",
3
+ "version": "0.29.33",
4
+ "description": "Cube.js Testing Helpers",
5
+ "author": "Cube Dev, Inc.",
6
+ "license": "Apache-2.0",
7
+ "main": "dist/src/index.js",
8
+ "typings": "dist/src/index.d.ts",
9
+ "engines": {
10
+ "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
11
+ },
12
+ "scripts": {
13
+ "build": "rm -rf dist && npm run tsc",
14
+ "tsc": "tsc",
15
+ "watch": "tsc -w",
16
+ "lint": "eslint src/* --ext .ts",
17
+ "lint:fix": "eslint --fix src/* --ext .ts"
18
+ },
19
+ "files": [
20
+ "dist/src/*"
21
+ ],
22
+ "dependencies": {
23
+ "@cubejs-backend/dotenv": "^9.0.2",
24
+ "@cubejs-backend/query-orchestrator": "^0.29.33",
25
+ "@cubejs-backend/schema-compiler": "^0.29.33",
26
+ "@cubejs-backend/shared": "^0.29.33",
27
+ "dedent": "^0.7.0",
28
+ "testcontainers": "^7.5.0"
29
+ },
30
+ "devDependencies": {
31
+ "@cubejs-backend/linter": "^0.29.23",
32
+ "@jest/globals": "^26.6.2",
33
+ "@types/dedent": "^0.7.0",
34
+ "@types/jest": "^26.0.22",
35
+ "@types/node": "^10.17.55",
36
+ "jest": "^26.6.3",
37
+ "typescript": "~4.1.5"
38
+ },
39
+ "jest": {
40
+ "coveragePathIgnorePatterns": [
41
+ ".*\\.d\\.ts"
42
+ ],
43
+ "testEnvironment": "node",
44
+ "testMatch": [
45
+ "<rootDir>/dist/test/*.(test|spec).(ts|js)"
46
+ ],
47
+ "snapshotResolver": "<rootDir>/test/snapshotResolver.js"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "eslintConfig": {
53
+ "extends": "../cubejs-linter"
54
+ },
55
+ "gitHead": "b52e4400b0786c37544b285de1e4c66dcee96e43"
56
+ }