File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed
packages/cubejs-schema-compiler/test/unit Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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 ( / " m e a s u r e s \. p a r e n t _ m e a s _ n o _ t y p e \. s q l " i s r e q u i r e d / ) ;
1030+ expect ( e . toString ( ) ) . toMatch ( / " m e a s u r e s \. p a r e n t _ m e a s _ n o _ t y p e \. t y p e " i s r e q u i r e d / ) ;
1031+ expect ( e . toString ( ) ) . toMatch ( / " m e a s u r e s \. p a r e n t _ m e a s _ b a d _ t y p e \. t y p e " m u s t b e o n e o f / ) ;
1032+ expect ( e . toString ( ) ) . toMatch ( / " d i m e n s i o n s \. p a r e n t _ d i m _ n o _ t y p e " d o e s n o t m a t c h a n y o f t h e a l l o w e d t y p e s / ) ;
1033+ expect ( e . toString ( ) ) . toMatch ( / " d i m e n s i o n s \. p a r e n t _ d i m _ n o _ s q l " d o e s n o t m a t c h a n y o f t h e a l l o w e d t y p e s / ) ;
1034+ expect ( e . toString ( ) ) . toMatch ( / " d i m e n s i o n s \. c h i l d _ d i m _ n o _ t y p e " d o e s n o t m a t c h a n y o f t h e a l l o w e d t y p e s / ) ;
1035+ expect ( e . toString ( ) ) . toMatch ( / " d i m e n s i o n s \. c h i l d _ d i m _ b a d _ t y p e " d o e s n o t m a t c h a n y o f t h e a l l o w e d t y p e s / ) ;
1036+ expect ( e . toString ( ) ) . toMatch ( / " d i m e n s i o n s \. c h i l d _ d i m _ n o _ s q l " d o e s n o t m a t c h a n y o f t h e a l l o w e d t y p e s / ) ;
1037+ }
1038+ } ) ;
10121039 } ) ;
10131040} ) ;
You can’t perform that action at this time.
0 commit comments