@malloydata/malloy-tests 0.0.127-dev240306172007 → 0.0.127-dev240308180053

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/databases/all/db_index.spec.js +2 -2
  2. package/dist/databases/all/db_index.spec.js.map +1 -1
  3. package/dist/databases/all/expr.spec.js +14 -14
  4. package/dist/databases/all/expr.spec.js.map +1 -1
  5. package/dist/databases/all/join.spec.js +2 -2
  6. package/dist/databases/all/join.spec.js.map +1 -1
  7. package/dist/databases/all/nomodel.spec.js +34 -34
  8. package/dist/databases/all/nomodel.spec.js.map +1 -1
  9. package/dist/databases/all/orderby.spec.js +4 -4
  10. package/dist/databases/all/orderby.spec.js.map +1 -1
  11. package/dist/databases/all/time.spec.js +22 -22
  12. package/dist/databases/all/time.spec.js.map +1 -1
  13. package/dist/databases/bigquery-postgres/multi_connection.spec.js +4 -7
  14. package/dist/databases/bigquery-postgres/multi_connection.spec.js.map +1 -1
  15. package/dist/databases/bigquery-postgres/streaming.spec.js +3 -0
  16. package/dist/databases/bigquery-postgres/streaming.spec.js.map +1 -1
  17. package/dist/databases/duckdb/duckdb.spec.js +1 -1
  18. package/dist/databases/duckdb/duckdb.spec.js.map +1 -1
  19. package/dist/databases/duckdb/streaming.spec.js +3 -0
  20. package/dist/databases/duckdb/streaming.spec.js.map +1 -1
  21. package/dist/render/render.spec.js +28 -28
  22. package/dist/render/render.spec.js.map +1 -1
  23. package/dist/util/index.d.ts +1 -1
  24. package/dist/util/index.js +17 -6
  25. package/dist/util/index.js.map +1 -1
  26. package/package.json +10 -7
  27. package/src/databases/all/db_index.spec.ts +4 -4
  28. package/src/databases/all/expr.spec.ts +41 -29
  29. package/src/databases/all/join.spec.ts +4 -4
  30. package/src/databases/all/nomodel.spec.ts +66 -60
  31. package/src/databases/all/orderby.spec.ts +7 -7
  32. package/src/databases/all/time.spec.ts +40 -37
  33. package/src/databases/bigquery-postgres/multi_connection.spec.ts +4 -6
  34. package/src/databases/bigquery-postgres/streaming.spec.ts +3 -0
  35. package/src/databases/duckdb/duckdb.spec.ts +1 -1
  36. package/src/databases/duckdb/streaming.spec.ts +3 -0
  37. package/src/render/render.spec.ts +162 -120
  38. package/src/util/index.ts +24 -4
@@ -29,16 +29,14 @@ import {EmptyURLReader} from '@malloydata/malloy';
29
29
  import {BigQueryTestConnection, PostgresTestConnection} from '../../runtimes';
30
30
  import {describeIfDatabaseAvailable} from '../../util';
31
31
 
32
- const res = describeIfDatabaseAvailable(['bigquery', 'postgres']);
33
- let [describe] = res;
34
- const [, databases] = res;
32
+ const [, databases] = describeIfDatabaseAvailable(['bigquery', 'postgres']);
35
33
 
36
34
  // *** NOTE ***
37
35
  // this is a special case (for now): a test that REQUIRES two databases - bigquery AND postgres
38
- describe =
36
+ const describe =
39
37
  databases.filter(d => ['postgres', 'bigquery'].includes(d)).length >= 2
40
- ? describe
41
- : describe.skip;
38
+ ? globalThis.describe
39
+ : globalThis.describe.skip;
42
40
 
43
41
  describe('Multi-connection', () => {
44
42
  const bqConnection = new BigQueryTestConnection(
@@ -48,6 +48,9 @@ const [describe, databases] = describeIfDatabaseAvailable([
48
48
  ]);
49
49
 
50
50
  describe('Streaming tests', () => {
51
+ if (!databases.length) {
52
+ it.skip('skipped', () => {});
53
+ }
51
54
  const runtimes = new RuntimeList(databases);
52
55
 
53
56
  afterAll(async () => {
@@ -29,7 +29,7 @@ import {describeIfDatabaseAvailable} from '../../util';
29
29
  // TODO identify which tests need to run on wasm and move them into their own file
30
30
  const runtimes = ['duckdb', 'duckdb_wasm'];
31
31
 
32
- const [_describe, databases] = describeIfDatabaseAvailable(runtimes);
32
+ const [describe, databases] = describeIfDatabaseAvailable(runtimes);
33
33
  const allDucks = new RuntimeList(databases);
34
34
 
35
35
  describe.each(allDucks.runtimeList)('duckdb:%s', (dbName, runtime) => {
@@ -90,6 +90,9 @@ function modelText(databaseName: string) {
90
90
  }
91
91
 
92
92
  describe('Streaming tests', () => {
93
+ if (!databases.length) {
94
+ it.skip('skipped', () => {});
95
+ }
93
96
  const runtimes = new RuntimeList(databases);
94
97
 
95
98
  afterAll(async () => {
@@ -23,7 +23,7 @@
23
23
 
24
24
  import {ModelMaterializer} from '@malloydata/malloy';
25
25
  import {RuntimeList, runtimeFor} from '../runtimes';
26
- import {describeIfDatabaseAvailable} from '../util';
26
+ import {describeIfDatabaseAvailable, onlyIf} from '../util';
27
27
  import {HTMLView} from '@malloydata/render';
28
28
  import {JSDOM} from 'jsdom';
29
29
 
@@ -66,130 +66,172 @@ describe('rendering results', () => {
66
66
  await runtimes.closeAll();
67
67
  });
68
68
 
69
- test('can render table', async () => {
70
- const runtime = runtimes.runtimeMap.get('bigquery');
71
- expect(runtime).toBeDefined();
72
- if (runtime) {
73
- const src = `
69
+ test(
70
+ 'can render table',
71
+ onlyIf(databases.includes('bigquery'), async () => {
72
+ const runtime = runtimes.runtimeMap.get('bigquery');
73
+ expect(runtime).toBeDefined();
74
+ if (runtime) {
75
+ const src = `
74
76
  run: bigquery.table('malloy-data.faa.flights') -> {
75
77
  group_by: carrier
76
78
  aggregate: flight_count is count()
77
79
  }
78
80
  `;
79
- const result = await runtime.loadQuery(src).run();
80
- const document = new JSDOM().window.document;
81
- await new HTMLView(document).render(result, {
82
- dataStyles: {},
83
- });
84
- }
85
- });
86
-
87
- test('can render unsupported bigquery geo types', async () => {
88
- await runUnsupportedRenderTest(
89
- 'bigquery',
90
- runtimes,
91
- "ST_GEOGFROMTEXT('LINESTRING(1 2, 3 4)')",
92
- 'LINESTRING(1 2, 3 4)'
93
- );
94
- });
95
-
96
- test('can render unsupported bigquery ip types', async () => {
97
- await runUnsupportedRenderTest(
98
- 'bigquery',
99
- runtimes,
100
- "NET.IP_FROM_STRING('192.168.1.1')",
101
- '{"type":"Buffer","data":[192,168,1,1]}'
102
- );
103
- });
104
-
105
- test('can render unsupported bigquery interval types', async () => {
106
- await runUnsupportedRenderTest(
107
- 'bigquery',
108
- runtimes,
109
- 'INTERVAL 1 YEAR',
110
- '1-0 0 0:0:0'
111
- );
112
- });
113
-
114
- test('can render unsupported bigquery time types', async () => {
115
- await runUnsupportedRenderTest(
116
- 'bigquery',
117
- runtimes,
118
- 'TIME(10, 10, 1)',
119
- '10:10:01'
120
- );
121
- });
122
-
123
- test('can render unsupported postgres interval types', async () => {
124
- await runUnsupportedRenderTest(
125
- 'postgres',
126
- runtimes,
127
- 'make_interval(days => 12)',
128
- '12 days'
129
- );
130
- });
131
-
132
- test('can render unsupported postgres uuid types', async () => {
133
- await runUnsupportedRenderTest(
134
- 'postgres',
135
- runtimes,
136
- "CAST('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11' AS UUID)",
137
- 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'
138
- );
139
- });
140
-
141
- test('can render unsupported postgres inet types', async () => {
142
- await runUnsupportedRenderTest(
143
- 'postgres',
144
- runtimes,
145
- "'192.168.1.1'::inet",
146
- '192.168.1.1'
147
- );
148
- });
149
-
150
- test('can render unsupported postgres macaddr types', async () => {
151
- await runUnsupportedRenderTest(
152
- 'postgres',
153
- runtimes,
154
- "'00:04:E2:36:95:C0'::macaddr",
155
- '00:04:e2:36:95:c0'
156
- );
157
- });
158
-
159
- test('can render supported postgres types', async () => {
160
- await runUnsupportedRenderTest('postgres', runtimes, '12345', '12,345');
161
- });
162
-
163
- test('can render supported duckdb types', async () => {
164
- await runUnsupportedRenderTest('duckdb', runtimes, '12345', '12,345');
165
- });
166
-
167
- test('can render unsupported duckdb blob types', async () => {
168
- await runUnsupportedRenderTest(
169
- 'duckdb',
170
- runtimes,
171
- "'\\xAA'::BLOB",
172
- '{"type":"Buffer","data":[170]}'
173
- );
174
- });
175
-
176
- test('can render unsupported duckdb uuid types', async () => {
177
- await runUnsupportedRenderTest(
178
- 'duckdb',
179
- runtimes,
180
- "'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::UUID",
181
- 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'
182
- );
183
- });
184
-
185
- test('can render null unsupported types', async () => {
186
- await runUnsupportedRenderTest(
187
- 'bigquery',
188
- runtimes,
189
- 'CAST(NULL AS GEOGRAPHY)',
190
- '<span class="value-null">∅</span>'
191
- );
192
- });
81
+ const result = await runtime.loadQuery(src).run();
82
+ const document = new JSDOM().window.document;
83
+ await new HTMLView(document).render(result, {
84
+ dataStyles: {},
85
+ });
86
+ }
87
+ })
88
+ );
89
+
90
+ test(
91
+ 'can render unsupported bigquery geo types',
92
+ onlyIf(databases.includes('bigquery'), async () => {
93
+ await runUnsupportedRenderTest(
94
+ 'bigquery',
95
+ runtimes,
96
+ "ST_GEOGFROMTEXT('LINESTRING(1 2, 3 4)')",
97
+ 'LINESTRING(1 2, 3 4)'
98
+ );
99
+ })
100
+ );
101
+
102
+ test(
103
+ 'can render unsupported bigquery ip types',
104
+ onlyIf(databases.includes('bigquery'), async () => {
105
+ await runUnsupportedRenderTest(
106
+ 'bigquery',
107
+ runtimes,
108
+ "NET.IP_FROM_STRING('192.168.1.1')",
109
+ '{"type":"Buffer","data":[192,168,1,1]}'
110
+ );
111
+ })
112
+ );
113
+
114
+ test(
115
+ 'can render unsupported bigquery interval types',
116
+ onlyIf(databases.includes('bigquery'), async () => {
117
+ await runUnsupportedRenderTest(
118
+ 'bigquery',
119
+ runtimes,
120
+ 'INTERVAL 1 YEAR',
121
+ '1-0 0 0:0:0'
122
+ );
123
+ })
124
+ );
125
+
126
+ test(
127
+ 'can render unsupported bigquery time types',
128
+ onlyIf(databases.includes('bigquery'), async () => {
129
+ await runUnsupportedRenderTest(
130
+ 'bigquery',
131
+ runtimes,
132
+ 'TIME(10, 10, 1)',
133
+ '10:10:01'
134
+ );
135
+ })
136
+ );
137
+
138
+ test(
139
+ 'can render unsupported postgres interval types',
140
+ onlyIf(databases.includes('postgres'), async () => {
141
+ await runUnsupportedRenderTest(
142
+ 'postgres',
143
+ runtimes,
144
+ 'make_interval(days => 12)',
145
+ '12 days'
146
+ );
147
+ })
148
+ );
149
+
150
+ test(
151
+ 'can render unsupported postgres uuid types',
152
+ onlyIf(databases.includes('postgres'), async () => {
153
+ await runUnsupportedRenderTest(
154
+ 'postgres',
155
+ runtimes,
156
+ "CAST('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11' AS UUID)",
157
+ 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'
158
+ );
159
+ })
160
+ );
161
+
162
+ test(
163
+ 'can render unsupported postgres inet types',
164
+ onlyIf(databases.includes('postgres'), async () => {
165
+ await runUnsupportedRenderTest(
166
+ 'postgres',
167
+ runtimes,
168
+ "'192.168.1.1'::inet",
169
+ '192.168.1.1'
170
+ );
171
+ })
172
+ );
173
+
174
+ test(
175
+ 'can render unsupported postgres macaddr types',
176
+ onlyIf(databases.includes('postgres'), async () => {
177
+ await runUnsupportedRenderTest(
178
+ 'postgres',
179
+ runtimes,
180
+ "'00:04:E2:36:95:C0'::macaddr",
181
+ '00:04:e2:36:95:c0'
182
+ );
183
+ })
184
+ );
185
+
186
+ test(
187
+ 'can render supported postgres types',
188
+ onlyIf(databases.includes('postgres'), async () => {
189
+ await runUnsupportedRenderTest('postgres', runtimes, '12345', '12,345');
190
+ })
191
+ );
192
+
193
+ test(
194
+ 'can render supported duckdb types',
195
+ onlyIf(databases.includes('duckdb'), async () => {
196
+ await runUnsupportedRenderTest('duckdb', runtimes, '12345', '12,345');
197
+ })
198
+ );
199
+
200
+ test(
201
+ 'can render unsupported duckdb blob types',
202
+ onlyIf(databases.includes('duckdb'), async () => {
203
+ await runUnsupportedRenderTest(
204
+ 'duckdb',
205
+ runtimes,
206
+ "'\\xAA'::BLOB",
207
+ '{"type":"Buffer","data":[170]}'
208
+ );
209
+ })
210
+ );
211
+
212
+ test(
213
+ 'can render unsupported duckdb uuid types',
214
+ onlyIf(databases.includes('duckdb'), async () => {
215
+ await runUnsupportedRenderTest(
216
+ 'duckdb',
217
+ runtimes,
218
+ "'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::UUID",
219
+ 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'
220
+ );
221
+ })
222
+ );
223
+
224
+ test(
225
+ 'can render null unsupported types',
226
+ onlyIf(databases.includes('bigquery'), async () => {
227
+ await runUnsupportedRenderTest(
228
+ 'bigquery',
229
+ runtimes,
230
+ 'CAST(NULL AS GEOGRAPHY)',
231
+ '<span class="value-null">∅</span>'
232
+ );
233
+ })
234
+ );
193
235
 
194
236
  describe('html renderer', () => {
195
237
  describe('complex query with tags', () => {
package/src/util/index.ts CHANGED
@@ -84,6 +84,19 @@ export function databasesFromEnvironmentOr(
84
84
  : defaultDatabases;
85
85
  }
86
86
 
87
+ const describeSkip: jest.Describe = Object.assign(
88
+ (
89
+ name: number | string | Function | jest.FunctionLike,
90
+ fn: jest.EmptyFunction
91
+ ) => describe.skip(name, fn),
92
+ {
93
+ skip: describe.skip,
94
+ // eslint-disable-next-line no-restricted-properties
95
+ only: describe.only,
96
+ each: (() => () => it.skip('skipped', () => {})) as unknown as jest.Each,
97
+ }
98
+ );
99
+
87
100
  // confirms that one or more of the databases being tested overlaps with the databases a test suite can accept.
88
101
  // if there is overlap, return a tuple of jest.describe and the dialects to be tested
89
102
  // if there is no overlap, return a tuple if jest.describe.skip and the dialects to be tested
@@ -93,7 +106,7 @@ export function describeIfDatabaseAvailable(
93
106
  const currentDatabases = databasesFromEnvironmentOr(acceptableDatabases);
94
107
  const overlap = acceptableDatabases.filter(d => currentDatabases.includes(d));
95
108
 
96
- return overlap.length > 0 ? [describe, overlap] : [describe.skip, overlap];
109
+ return overlap.length > 0 ? [describe, overlap] : [describeSkip, overlap];
97
110
  }
98
111
 
99
112
  interface InitValues {
@@ -206,6 +219,13 @@ export async function runQuery(runtime: Runtime, querySrc: string) {
206
219
  return result;
207
220
  }
208
221
 
209
- export const testIf = (condition: boolean) => {
210
- return condition ? test : test.skip;
211
- };
222
+ export function onlyIf(
223
+ cond: boolean,
224
+ condTest: jest.ProvidesCallback
225
+ ): jest.ProvidesCallback {
226
+ if (cond) {
227
+ return condTest;
228
+ } else {
229
+ return () => {};
230
+ }
231
+ }