Skip to content

Commit 16c24ec

Browse files
committed
add tests
1 parent 0c83b0e commit 16c24ec

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
@@ -1009,5 +1009,32 @@ describe('Schema Testing', () => {
10091009
expect(cubeB.sqlTable).toBeTruthy();
10101010
expect(cubeB.sql).toBeFalsy();
10111011
});
1012+
1013+
it('throws error for member without type in cubeB extending cubeA', async () => {
1014+
const cubes = fs.readFileSync(
1015+
path.join(process.cwd(), '/test/unit/fixtures/invalid_cubes.yaml'),
1016+
'utf8'
1017+
);
1018+
const { compiler } = prepareCompiler([
1019+
{
1020+
content: cubes,
1021+
fileName: 'invalid_cubes.yaml',
1022+
},
1023+
]);
1024+
1025+
try {
1026+
await compiler.compile();
1027+
throw new Error('should throw earlier');
1028+
} catch (e: any) {
1029+
expect(e.toString()).toMatch(/"measures\.parent_meas_no_type\.sql" is required/);
1030+
expect(e.toString()).toMatch(/"measures\.parent_meas_no_type\.type" is required/);
1031+
expect(e.toString()).toMatch(/"measures\.parent_meas_bad_type\.type" must be one of/);
1032+
expect(e.toString()).toMatch(/"dimensions\.parent_dim_no_type" does not match any of the allowed types/);
1033+
expect(e.toString()).toMatch(/"dimensions\.parent_dim_no_sql" does not match any of the allowed types/);
1034+
expect(e.toString()).toMatch(/"dimensions\.child_dim_no_type" does not match any of the allowed types/);
1035+
expect(e.toString()).toMatch(/"dimensions\.child_dim_bad_type" does not match any of the allowed types/);
1036+
expect(e.toString()).toMatch(/"dimensions\.child_dim_no_sql" does not match any of the allowed types/);
1037+
}
1038+
});
10121039
});
10131040
});

0 commit comments

Comments
 (0)