Skip to content

Commit 8642671

Browse files
committed
add tests
1 parent 8756938 commit 8642671

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
cubes:
2+
- name: base_cube
3+
sql_table: foo
4+
5+
dimensions:
6+
- name: status
7+
sql: status
8+
type: string
9+
10+
- name: parent_dim_no_type
11+
sql: barbus
12+
13+
- name: parent_dim_bad_type
14+
type: bad_type
15+
sql: badus
16+
17+
- name: parent_dim_no_sql
18+
type: string
19+
20+
measures:
21+
- name: count
22+
type: count
23+
24+
- name: parent_meas_no_type
25+
26+
- name: parent_meas_bad_type
27+
type: bad_type
28+
29+
- name: child_cube
30+
extends: base_cube
31+
32+
dimensions:
33+
- name: bar
34+
sql: bar
35+
type: string
36+
37+
- name: child_dim_no_type
38+
sql: barbus
39+
40+
- name: child_dim_bad_type
41+
type: bad_type
42+
sql: shmarbus
43+
44+
- name: child_dim_no_sql
45+
type: number

packages/cubejs-schema-compiler/test/unit/schema.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,5 +1013,32 @@ describe('Schema Testing', () => {
10131013
expect(cubeB.sqlTable).toBeTruthy();
10141014
expect(cubeB.sql).toBeFalsy();
10151015
});
1016+
1017+
it('throws error for member without type in cubeB extending cubeA', async () => {
1018+
const cubes = fs.readFileSync(
1019+
path.join(process.cwd(), '/test/unit/fixtures/invalid_cubes.yaml'),
1020+
'utf8'
1021+
);
1022+
const { compiler } = prepareCompiler([
1023+
{
1024+
content: cubes,
1025+
fileName: 'invalid_cubes.yaml',
1026+
},
1027+
]);
1028+
1029+
try {
1030+
await compiler.compile();
1031+
throw new Error('should throw earlier');
1032+
} catch (e: any) {
1033+
expect(e.toString()).toMatch(/"measures\.parent_meas_no_type\.sql" is required/);
1034+
expect(e.toString()).toMatch(/"measures\.parent_meas_no_type\.type" is required/);
1035+
expect(e.toString()).toMatch(/"measures\.parent_meas_bad_type\.type" must be one of/);
1036+
expect(e.toString()).toMatch(/"dimensions\.parent_dim_no_type" does not match any of the allowed types/);
1037+
expect(e.toString()).toMatch(/"dimensions\.parent_dim_no_sql" does not match any of the allowed types/);
1038+
expect(e.toString()).toMatch(/"dimensions\.child_dim_no_type" does not match any of the allowed types/);
1039+
expect(e.toString()).toMatch(/"dimensions\.child_dim_bad_type" does not match any of the allowed types/);
1040+
expect(e.toString()).toMatch(/"dimensions\.child_dim_no_sql" does not match any of the allowed types/);
1041+
}
1042+
});
10161043
});
10171044
});

0 commit comments

Comments
 (0)