Skip to content

Commit 2e8dafa

Browse files
committed
add tests for calendar cubes in schema compiler
1 parent 674dde7 commit 2e8dafa

File tree

5 files changed

+773
-0
lines changed

5 files changed

+773
-0
lines changed

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

Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,339 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`Schema Testing Calendar Cubes Valid calendar cubes: customCalendarJsCube 1`] = `
4+
Object {
5+
"accessPolicy": undefined,
6+
"allDefinitions": [Function],
7+
"calendar": true,
8+
"dimensions": Object {
9+
"date_val": Object {
10+
"ownedByCube": true,
11+
"primaryKey": true,
12+
"shown": true,
13+
"sql": [Function],
14+
"type": "time",
15+
},
16+
"fiscal_month_number": Object {
17+
"ownedByCube": true,
18+
"sql": [Function],
19+
"type": "string",
20+
},
21+
"fiscal_month_short_name": Object {
22+
"ownedByCube": true,
23+
"sql": [Function],
24+
"type": "string",
25+
},
26+
"fiscal_quarter_year": Object {
27+
"ownedByCube": true,
28+
"sql": [Function],
29+
"type": "string",
30+
},
31+
"fiscal_week_begin_date": Object {
32+
"ownedByCube": true,
33+
"sql": [Function],
34+
"type": "time",
35+
},
36+
"fiscal_week_end_date": Object {
37+
"ownedByCube": true,
38+
"sql": [Function],
39+
"type": "time",
40+
},
41+
"fiscal_week_name": Object {
42+
"ownedByCube": true,
43+
"sql": [Function],
44+
"type": "string",
45+
},
46+
"fiscal_year": Object {
47+
"ownedByCube": true,
48+
"sql": [Function],
49+
"type": "string",
50+
},
51+
"fiscal_year_month_name": Object {
52+
"ownedByCube": true,
53+
"sql": [Function],
54+
"type": "string",
55+
},
56+
"fiscal_year_month_number": Object {
57+
"ownedByCube": true,
58+
"sql": [Function],
59+
"type": "number",
60+
},
61+
"fiscal_year_period_name": Object {
62+
"ownedByCube": true,
63+
"sql": [Function],
64+
"type": "number",
65+
},
66+
"retail_date": Object {
67+
"granularities": Object {
68+
"month": Object {
69+
"sql": [Function],
70+
},
71+
"quarter": Object {
72+
"sql": [Function],
73+
},
74+
"week": Object {
75+
"sql": [Function],
76+
},
77+
"year": Object {
78+
"sql": [Function],
79+
},
80+
},
81+
"ownedByCube": true,
82+
"sql": [Function],
83+
"type": "time",
84+
},
85+
"retail_month_begin_date": Object {
86+
"ownedByCube": true,
87+
"sql": [Function],
88+
"type": "string",
89+
},
90+
"retail_month_long_name": Object {
91+
"ownedByCube": true,
92+
"sql": [Function],
93+
"type": "string",
94+
},
95+
"retail_quarter_year": Object {
96+
"ownedByCube": true,
97+
"sql": [Function],
98+
"type": "string",
99+
},
100+
"retail_week_begin_date": Object {
101+
"ownedByCube": true,
102+
"sql": [Function],
103+
"type": "string",
104+
},
105+
"retail_week_in_month": Object {
106+
"ownedByCube": true,
107+
"sql": [Function],
108+
"type": "string",
109+
},
110+
"retail_week_name": Object {
111+
"ownedByCube": true,
112+
"sql": [Function],
113+
"type": "string",
114+
},
115+
"retail_year": Object {
116+
"ownedByCube": true,
117+
"sql": [Function],
118+
"type": "string",
119+
},
120+
"retail_year_begin_date": Object {
121+
"ownedByCube": true,
122+
"sql": [Function],
123+
"type": "time",
124+
},
125+
"retail_year_end_date": Object {
126+
"ownedByCube": true,
127+
"sql": [Function],
128+
"type": "time",
129+
},
130+
"retail_year_week": Object {
131+
"ownedByCube": true,
132+
"sql": [Function],
133+
"type": "string",
134+
},
135+
},
136+
"fileName": "custom_calendar.js",
137+
"hierarchies": Object {},
138+
"joins": Object {},
139+
"measures": Object {
140+
"count": Object {
141+
"ownedByCube": true,
142+
"type": "count",
143+
},
144+
},
145+
"name": "custom_calendar_js",
146+
"preAggregations": Object {},
147+
"rawCubes": [Function],
148+
"rawFolders": [Function],
149+
"segments": Object {},
150+
"sql": [Function],
151+
}
152+
`;
153+
154+
exports[`Schema Testing Calendar Cubes Valid calendar cubes: customCalendarYamlCube 1`] = `
155+
Object {
156+
"accessPolicy": undefined,
157+
"allDefinitions": [Function],
158+
"calendar": true,
159+
"dimensions": Object {
160+
"date_val": Object {
161+
"ownedByCube": true,
162+
"primaryKey": true,
163+
"sql": [Function],
164+
"type": "time",
165+
},
166+
"fiscal_month_number": Object {
167+
"ownedByCube": true,
168+
"sql": [Function],
169+
"type": "string",
170+
},
171+
"fiscal_month_short_name": Object {
172+
"ownedByCube": true,
173+
"sql": [Function],
174+
"type": "string",
175+
},
176+
"fiscal_quarter_year": Object {
177+
"ownedByCube": true,
178+
"sql": [Function],
179+
"type": "string",
180+
},
181+
"fiscal_week_begin_date": Object {
182+
"ownedByCube": true,
183+
"sql": [Function],
184+
"type": "time",
185+
},
186+
"fiscal_week_end_date": Object {
187+
"ownedByCube": true,
188+
"sql": [Function],
189+
"type": "time",
190+
},
191+
"fiscal_week_name": Object {
192+
"ownedByCube": true,
193+
"sql": [Function],
194+
"type": "string",
195+
},
196+
"fiscal_year": Object {
197+
"ownedByCube": true,
198+
"sql": [Function],
199+
"type": "string",
200+
},
201+
"fiscal_year_month_name": Object {
202+
"ownedByCube": true,
203+
"sql": [Function],
204+
"type": "string",
205+
},
206+
"fiscal_year_month_number": Object {
207+
"ownedByCube": true,
208+
"sql": [Function],
209+
"type": "number",
210+
},
211+
"fiscal_year_period_name": Object {
212+
"ownedByCube": true,
213+
"sql": [Function],
214+
"type": "number",
215+
},
216+
"retail_date": Object {
217+
"granularities": Object {
218+
"fortnight": Object {
219+
"interval": "2 week",
220+
"origin": "2025-01-01",
221+
},
222+
"month": Object {
223+
"sql": [Function],
224+
},
225+
"quarter": Object {
226+
"sql": [Function],
227+
},
228+
"week": Object {
229+
"sql": [Function],
230+
},
231+
"year": Object {
232+
"sql": [Function],
233+
},
234+
},
235+
"ownedByCube": true,
236+
"sql": [Function],
237+
"type": "time",
238+
},
239+
"retail_month_begin_date": Object {
240+
"ownedByCube": true,
241+
"sql": [Function],
242+
"type": "string",
243+
},
244+
"retail_month_long_name": Object {
245+
"ownedByCube": true,
246+
"sql": [Function],
247+
"type": "string",
248+
},
249+
"retail_quarter_year": Object {
250+
"ownedByCube": true,
251+
"sql": [Function],
252+
"type": "string",
253+
},
254+
"retail_week_begin_date": Object {
255+
"ownedByCube": true,
256+
"sql": [Function],
257+
"type": "string",
258+
},
259+
"retail_week_in_month": Object {
260+
"ownedByCube": true,
261+
"sql": [Function],
262+
"type": "string",
263+
},
264+
"retail_week_name": Object {
265+
"ownedByCube": true,
266+
"sql": [Function],
267+
"type": "string",
268+
},
269+
"retail_year": Object {
270+
"ownedByCube": true,
271+
"sql": [Function],
272+
"type": "string",
273+
},
274+
"retail_year_begin_date": Object {
275+
"ownedByCube": true,
276+
"sql": [Function],
277+
"type": "time",
278+
},
279+
"retail_year_end_date": Object {
280+
"ownedByCube": true,
281+
"sql": [Function],
282+
"type": "time",
283+
},
284+
"retail_year_week": Object {
285+
"ownedByCube": true,
286+
"sql": [Function],
287+
"type": "string",
288+
},
289+
},
290+
"evaluatedHierarchies": Array [
291+
Object {
292+
"levels": Array [
293+
"custom_calendar.fiscal_year",
294+
"custom_calendar.fiscal_quarter_year",
295+
"custom_calendar.fiscal_month_number",
296+
],
297+
"name": "Fiscal_Calendar_Hierarchy",
298+
"title": "Fiscal Calendar Hierarchy",
299+
},
300+
Object {
301+
"levels": Array [
302+
"custom_calendar.retail_year",
303+
"custom_calendar.retail_month_long_name",
304+
"custom_calendar.retail_week_name",
305+
],
306+
"name": "Retail_Calendar_Hierarchy",
307+
"title": "Retail Calendar Hierarchy",
308+
},
309+
],
310+
"fileName": "custom_calendar.yml",
311+
"hierarchies": Object {
312+
"Fiscal_Calendar_Hierarchy": Object {
313+
"levels": [Function],
314+
"title": "Fiscal Calendar Hierarchy",
315+
},
316+
"Retail_Calendar_Hierarchy": Object {
317+
"levels": [Function],
318+
"title": "Retail Calendar Hierarchy",
319+
},
320+
},
321+
"joins": Object {},
322+
"measures": Object {
323+
"count": Object {
324+
"ownedByCube": true,
325+
"type": "count",
326+
},
327+
},
328+
"name": "custom_calendar",
329+
"preAggregations": Object {},
330+
"rawCubes": [Function],
331+
"rawFolders": [Function],
332+
"segments": Object {},
333+
"sqlTable": [Function],
334+
}
335+
`;
336+
3337
exports[`Schema Testing Inheritance CubeB.js correctly extends cubeA.js (no additions): accessPolicy 1`] = `
4338
Array [
5339
Object {

0 commit comments

Comments
 (0)