@malloydata/malloy-tests 0.0.315 → 0.0.316

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.
package/package.json CHANGED
@@ -21,14 +21,14 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@jest/globals": "^29.4.3",
24
- "@malloydata/db-bigquery": "0.0.315",
25
- "@malloydata/db-duckdb": "0.0.315",
26
- "@malloydata/db-postgres": "0.0.315",
27
- "@malloydata/db-snowflake": "0.0.315",
28
- "@malloydata/db-trino": "0.0.315",
29
- "@malloydata/malloy": "0.0.315",
30
- "@malloydata/malloy-tag": "0.0.315",
31
- "@malloydata/render": "0.0.315",
24
+ "@malloydata/db-bigquery": "0.0.316",
25
+ "@malloydata/db-duckdb": "0.0.316",
26
+ "@malloydata/db-postgres": "0.0.316",
27
+ "@malloydata/db-snowflake": "0.0.316",
28
+ "@malloydata/db-trino": "0.0.316",
29
+ "@malloydata/malloy": "0.0.316",
30
+ "@malloydata/malloy-tag": "0.0.316",
31
+ "@malloydata/render": "0.0.316",
32
32
  "events": "^3.3.0",
33
33
  "jsdom": "^22.1.0",
34
34
  "luxon": "^2.4.0",
@@ -38,5 +38,5 @@
38
38
  "@types/jsdom": "^21.1.1",
39
39
  "@types/luxon": "^2.4.0"
40
40
  },
41
- "version": "0.0.315"
41
+ "version": "0.0.316"
42
42
  }
@@ -51,3 +51,7 @@ describe('misc tests for regressions that have no better home', () => {
51
51
  }
52
52
  });
53
53
  });
54
+
55
+ afterAll(async () => {
56
+ await runtime.connection.close();
57
+ });
@@ -121,3 +121,7 @@ describe('emits events', () => {
121
121
  });
122
122
  });
123
123
  });
124
+
125
+ afterAll(async () => {
126
+ await runtime.connection.close();
127
+ });
@@ -74,10 +74,7 @@ describe('experimental dialects', () => {
74
74
  }
75
75
  }
76
76
 
77
- const connection = new DuckdbXConnection(
78
- duckdbX,
79
- 'test/data/duckdb/duckdb_test.db'
80
- );
77
+ const connection = new DuckdbXConnection(duckdbX, ':memory:');
81
78
 
82
79
  class DuckdbXDialect extends DuckDBDialect {
83
80
  experimental = true;
@@ -45,3 +45,7 @@ describe('turducken', () => {
45
45
  expect(qsql).toContain(`FROM (${sql}) as base`);
46
46
  });
47
47
  });
48
+
49
+ afterAll(async () => {
50
+ await runtime.connection.close();
51
+ });
@@ -348,3 +348,7 @@ describe('tags in results', () => {
348
348
  expect(tags.has('n4')).toBeTruthy();
349
349
  });
350
350
  });
351
+
352
+ afterAll(async () => {
353
+ await runtime.connection.close();
354
+ });
@@ -0,0 +1,24 @@
1
+ import {RuntimeList, allDatabases} from '../../runtimes';
2
+ import {databasesFromEnvironmentOr} from '../../util';
3
+ import '../../util/db-jest-matchers';
4
+
5
+ const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
6
+
7
+ describe.each(runtimes.runtimeList)(
8
+ 'connection close test %s',
9
+ (conName, runtime) => {
10
+ const n = runtime.dialect.sqlMaybeQuoteIdentifier('n');
11
+ test.each(Array.from({length: 50}, (_, i) => i + 1))(
12
+ 'run SELECT %i',
13
+ async queryNum => {
14
+ await expect(`
15
+ run: ${conName}.sql("""SELECT ${queryNum} as ${n} """)
16
+ `).malloyResultMatches(runtime, {n: queryNum});
17
+ }
18
+ );
19
+ }
20
+ );
21
+
22
+ afterAll(async () => {
23
+ await runtimes.closeAll();
24
+ });
@@ -766,3 +766,7 @@ describe('unsupported type tests', () => {
766
766
  expect(result.data.value[0]['geo']).toBeDefined();
767
767
  });
768
768
  });
769
+
770
+ afterAll(async () => {
771
+ await runtimeList.closeAll();
772
+ });
@@ -102,3 +102,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
102
102
  expect(model3._modelDef.contents['a']).not.toBeDefined();
103
103
  });
104
104
  });
105
+
106
+ afterAll(async () => {
107
+ await runtimes.closeAll();
108
+ });
package/src/runtimes.ts CHANGED
@@ -132,6 +132,17 @@ export class DuckDBTestConnection extends DuckDBConnection {
132
132
  }
133
133
  }
134
134
 
135
+ export class DuckDBROTestConnection extends DuckDBTestConnection {
136
+ constructor(name: string, databasePath?: string, workingDirectory?: string) {
137
+ super({
138
+ name,
139
+ databasePath,
140
+ workingDirectory,
141
+ readOnly: true,
142
+ });
143
+ }
144
+ }
145
+
135
146
  export class DuckDBWASMTestConnection extends DuckDBWASMConnection {
136
147
  // we probably need a better way to do this.
137
148
 
@@ -190,6 +201,12 @@ export function runtimeFor(dbName: string): SingleConnectionRuntime {
190
201
  connection = new PostgresTestConnection(dbName);
191
202
  break;
192
203
  case 'duckdb':
204
+ connection = new DuckDBROTestConnection(
205
+ dbName,
206
+ 'test/data/duckdb/duckdb_test.db'
207
+ );
208
+ break;
209
+ case 'duckdb_rw':
193
210
  connection = new DuckDBTestConnection(
194
211
  dbName,
195
212
  'test/data/duckdb/duckdb_test.db'
@@ -298,8 +315,8 @@ export class RuntimeList {
298
315
  for (const [_key, runtime] of this.runtimeMap) {
299
316
  await runtime.connection.close();
300
317
  }
301
- // Unfortunate hack to avoid slow to die background threads tripping
302
- // up jest
303
- await new Promise(resolve => setTimeout(resolve, 10000));
318
+ // TODO delete this line if it turns out not to be needed.
319
+ // At one time duckdb_wasm needed this
320
+ // await new Promise(resolve => setTimeout(resolve, 2000));
304
321
  }
305
322
  }