Skip to content

Commit 598a87b

Browse files
committed
trying to add smoke tests...
1 parent c52ef33 commit 598a87b

File tree

4 files changed

+58
-7
lines changed

4 files changed

+58
-7
lines changed

packages/cubejs-testing/test/driver-postgres.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
import { mainTestSet, preAggsTestSet, productionTestSet } from './driverTests/testSets';
1+
import { mainTestSet, multiQueryTestSet, preAggsTestSet, productionTestSet } from './driverTests/testSets';
22
import { executeTestSuite } from './driver-test-suite';
33

44
executeTestSuite({
55
type: 'postgres',
66
tests: mainTestSet,
77
});
88

9+
executeTestSuite({
10+
type: 'postgres',
11+
tests: multiQueryTestSet,
12+
});
13+
914
executeTestSuite({
1015
type: 'postgres',
1116
tests: mainTestSet,

packages/cubejs-testing/test/driverTests/driverTest.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type TestType = 'basic' | 'withError' | 'testFn';
77

88
type DriverTestArg = {
99
name: string;
10-
query: Query;
10+
query: Query | Query[];
1111
expectArray?: ((response: ResultSet<QueryRecordType<Query>>) => any)[];
1212
schemas: Schemas;
1313
skip?: boolean;
@@ -23,7 +23,7 @@ type DriverTestWithErrorArg = {
2323

2424
export type DriverTestBasic = {
2525
name: string,
26-
query: Query,
26+
query: Query | Query[],
2727
expectArray?: ((response: ResultSet<QueryRecordType<Query>>) => any)[]
2828
schemas: Schemas,
2929
skip?: boolean;
@@ -32,13 +32,22 @@ export type DriverTestBasic = {
3232

3333
export type DriverTestWithError = {
3434
name: string;
35-
query: Query;
35+
query: Query | Query[];
3636
expectArray?: ((e: Error) => any)[];
3737
schemas: Schemas;
3838
skip?: boolean;
3939
type: 'withError';
4040
};
4141

42+
export type DriverTestMulti = {
43+
name: string,
44+
query: Query | Query[],
45+
expectArray?: ((response: ResultSet<QueryRecordType<Query[]>>) => any)[]
46+
schemas: Schemas,
47+
skip?: boolean;
48+
type: 'multi';
49+
};
50+
4251
type DriverTestFnArg = {
4352
name: string;
4453
schemas: Schemas,
@@ -50,7 +59,7 @@ export type DriverTestFn = DriverTestFnArg & {
5059
type: 'testFn';
5160
};
5261

53-
export type DriverTest = DriverTestBasic | DriverTestWithError | DriverTestFn;
62+
export type DriverTest = DriverTestBasic | DriverTestWithError | DriverTestFn | DriverTestMulti;
5463

5564
export function driverTest(
5665
{ name, query, expectArray = [], skip, schemas }: DriverTestArg
@@ -70,6 +79,12 @@ export function driverTestFn(
7079
return { name, testFn, schemas, skip, type: 'testFn' };
7180
}
7281

82+
export function driverTestMulti(
83+
{ name, query, expectArray = [], skip, schemas }: DriverTestArg
84+
): DriverTestMulti {
85+
return { name, query, expectArray, schemas, skip, type: 'multi' };
86+
}
87+
7388
export function testSet(tests: DriverTest[]) {
7489
const uniqTests = uniqBy((t) => t.name, tests);
7590
return uniqTests;

packages/cubejs-testing/test/driverTests/testSets.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import {
6262
hiddenCube,
6363
viewMetaExposed,
6464
preAggsCustomersRunningTotal,
65+
queryingECommerceCompareDateRangesByCustomerOverProductNameByMonth,
6566
} from './tests';
6667
import { testSet } from './driverTest';
6768

@@ -156,3 +157,7 @@ export const productionTestSet = testSet([
156157
hiddenMember,
157158
hiddenCube,
158159
]);
160+
161+
export const multiQueryTestSet = [
162+
queryingECommerceCompareDateRangesByCustomerOverProductNameByMonth,
163+
];

packages/cubejs-testing/test/driverTests/tests.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// eslint-disable-next-line import/no-extraneous-dependencies
22
import { expect } from '@jest/globals';
3-
import { driverTest, driverTestFn, driverTestWithError } from './driverTest';
3+
import { driverTest, driverTestFn, driverTestMulti, driverTestWithError } from './driverTest';
44

55
const commonSchemas = [
66
'CAST.js',
@@ -189,7 +189,7 @@ export const filteringCustomersCubeThird = driverTest(
189189
},
190190
schemas: commonSchemas,
191191
}
192-
192+
193193
);
194194

195195
export const filteringCustomersEndsWithFilterFirst = driverTest({
@@ -1296,6 +1296,32 @@ export const preAggsCustomersRunningTotal = driverTest({
12961296
schemas: commonSchemas
12971297
});
12981298

1299+
export const queryingECommerceCompareDateRangesByCustomerOverProductNameByMonth = driverTestMulti({
1300+
name: 'querying ECommerce: compare DateRanges by customer over productName by month',
1301+
query: [{
1302+
timeDimensions: [{
1303+
dimension: 'ECommerce.orderDate',
1304+
granularity: 'month',
1305+
compareDateRange: [
1306+
['2023-01-01', '2024-01-01'],
1307+
['2024-01-01', '2025-01-01']
1308+
]
1309+
}],
1310+
dimensions: [
1311+
'ECommerce.productName'
1312+
],
1313+
measures: [
1314+
'ECommerce.countApproxByCustomer'
1315+
],
1316+
order: {
1317+
'ECommerce.orderDate': 'desc',
1318+
'ECommerce.countApproxByCustomer': 'desc',
1319+
'ECommerce.productName': 'asc',
1320+
},
1321+
}],
1322+
schemas: commonSchemas
1323+
});
1324+
12991325
export const queryingEcommerceTotalQuantifyAvgDiscountTotal = driverTestWithError({
13001326
name: 'querying ECommerce: total quantity, avg discount, total ' +
13011327
'sales, total profit by product + order + total -- noisy ' +

0 commit comments

Comments
 (0)