pogi 3.0.1 → 3.2.0

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 (56) hide show
  1. package/.env +6 -5
  2. package/.vscode/launch.json +51 -12
  3. package/CHANGELOG.md +48 -0
  4. package/jest.config.js +31 -21
  5. package/jest.globalSetup.js +18 -0
  6. package/jest.globalTeardown.js +6 -0
  7. package/jest.setup.ts +22 -0
  8. package/lib/bin/generateInterface.js +40 -45
  9. package/lib/bin/generateInterface.js.map +1 -1
  10. package/lib/connectionOptions.d.ts +1 -1
  11. package/lib/connectionOptions.js +1 -2
  12. package/lib/index.d.ts +6 -6
  13. package/lib/index.js +3 -9
  14. package/lib/index.js.map +1 -1
  15. package/lib/pgConverters.js +12 -22
  16. package/lib/pgConverters.js.map +1 -1
  17. package/lib/pgConverters.test.js +7 -10
  18. package/lib/pgConverters.test.js.map +1 -1
  19. package/lib/pgDb.d.ts +7 -7
  20. package/lib/pgDb.js +551 -596
  21. package/lib/pgDb.js.map +1 -1
  22. package/lib/pgDb.test.js +546 -548
  23. package/lib/pgDb.test.js.map +1 -1
  24. package/lib/pgDbInterface.d.ts +2 -2
  25. package/lib/pgDbInterface.js +2 -5
  26. package/lib/pgDbInterface.js.map +1 -1
  27. package/lib/pgDbLogger.js +1 -2
  28. package/lib/pgDbOperators.js +3 -5
  29. package/lib/pgDbOperators.js.map +1 -1
  30. package/lib/pgDbOperators.test.js +155 -158
  31. package/lib/pgDbOperators.test.js.map +1 -1
  32. package/lib/pgSchema.d.ts +2 -2
  33. package/lib/pgSchema.js +7 -8
  34. package/lib/pgSchema.js.map +1 -1
  35. package/lib/pgTable.d.ts +8 -9
  36. package/lib/pgTable.js +178 -217
  37. package/lib/pgTable.js.map +1 -1
  38. package/lib/pgTableInterface.d.ts +1 -1
  39. package/lib/pgTableInterface.js +1 -2
  40. package/lib/pgTableInterface.js.map +1 -1
  41. package/lib/pgUtils.d.ts +10 -10
  42. package/lib/pgUtils.js +36 -45
  43. package/lib/pgUtils.js.map +1 -1
  44. package/lib/queryAble.d.ts +5 -6
  45. package/lib/queryAble.js +248 -264
  46. package/lib/queryAble.js.map +1 -1
  47. package/lib/queryAbleInterface.d.ts +5 -6
  48. package/lib/queryAbleInterface.js +1 -2
  49. package/lib/queryAbleInterface.js.map +1 -1
  50. package/lib/queryWhere.d.ts +1 -1
  51. package/lib/queryWhere.js +20 -23
  52. package/lib/queryWhere.js.map +1 -1
  53. package/lib/test/pgServiceRestartTest.js +617 -648
  54. package/lib/test/pgServiceRestartTest.js.map +1 -1
  55. package/package.json +27 -26
  56. package/tsconfig.json +6 -12
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const pgDb_1 = require("../pgDb");
5
- const yargs = require("yargs");
6
- const shell = require("shelljs");
7
- let argv = yargs
1
+ import shell from "shelljs";
2
+ import yargs from 'yargs';
3
+ import { PgDb } from "../pgDb.js";
4
+ let argv = await yargs(process.argv.slice(2))
8
5
  .usage('node pgServiceRestartTest.js\n Usage: $0')
9
6
  .option('postgresOn', {
10
7
  describe: 'the command line command which switches on the postgresql server',
@@ -19,19 +16,15 @@ let argv = yargs
19
16
  type: "boolean"
20
17
  })
21
18
  .argv;
22
- function runCommand(command, options) {
23
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
- return new Promise((resolve, reject) => {
25
- shell.exec(command, { silent: options ? options.silent : true }, (code, stdout, stderr) => {
26
- resolve({ stdout, stderr });
27
- });
19
+ async function runCommand(command, options) {
20
+ return new Promise((resolve, reject) => {
21
+ shell.exec(command, { silent: options ? options.silent : true }, (code, stdout, stderr) => {
22
+ resolve({ stdout, stderr });
28
23
  });
29
24
  });
30
25
  }
31
- function asyncWaitMs(ms) {
32
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
33
- yield new Promise(r => setTimeout(r, ms));
34
- });
26
+ async function asyncWaitMs(ms) {
27
+ await new Promise(r => setTimeout(r, ms));
35
28
  }
36
29
  function syncWaitMs(ms) {
37
30
  let origDate = +new Date();
@@ -40,228 +33,208 @@ function syncWaitMs(ms) {
40
33
  actDate = +new Date();
41
34
  }
42
35
  }
43
- function postgresOff() {
44
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
45
- console.log('Kill postgres server.');
46
- yield runCommand(argv.postgresOff);
47
- });
36
+ async function postgresOff() {
37
+ console.log('Kill postgres server.');
38
+ await runCommand(argv.postgresOff);
48
39
  }
49
- function postgresOn() {
50
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
51
- console.log('Start postgres server.');
52
- yield runCommand(argv.postgresOn);
53
- yield asyncWaitMs(500);
54
- });
40
+ async function postgresOn() {
41
+ console.log('Start postgres server.');
42
+ await runCommand(argv.postgresOn);
43
+ await asyncWaitMs(500);
55
44
  }
56
45
  const poolSize = 3;
57
- function testSchemaClear(db) {
58
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
59
- yield db.run(`drop table if exists pgdb_test.names`);
60
- yield db.run(`DROP TYPE IF EXISTS pgdb_test.mood CASCADE`);
61
- yield db.run(`DROP TABLE IF EXISTS pgdb_test."enumArrayTable"`);
62
- });
46
+ async function testSchemaClear(db) {
47
+ await db.run(`drop table if exists pgdb_test.names`);
48
+ await db.run(`DROP TYPE IF EXISTS pgdb_test.mood CASCADE`);
49
+ await db.run(`DROP TABLE IF EXISTS pgdb_test."enumArrayTable"`);
63
50
  }
64
- function testSchemaInit(db) {
65
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
66
- yield testSchemaClear(db);
67
- yield db.run(`create table pgdb_test.names (name varchar null)`);
68
- yield db.run(`insert into pgdb_test.names (name) values ('Kuka'), ('Hapci')`);
69
- yield db.run(`CREATE TYPE pgdb_test.mood AS ENUM('sad', 'ok', 'happy')`);
70
- yield db.run(`CREATE TABLE pgdb_test."enumArrayTable"(m pgdb_test.mood[] NULL)`);
71
- yield db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values (ARRAY['sad'::pgdb_test.mood, 'happy'::pgdb_test.mood])`);
72
- });
51
+ async function testSchemaInit(db) {
52
+ await testSchemaClear(db);
53
+ await db.run(`create table pgdb_test.names (name varchar null)`);
54
+ await db.run(`insert into pgdb_test.names (name) values ('Kuka'), ('Hapci')`);
55
+ await db.run(`CREATE TYPE pgdb_test.mood AS ENUM('sad', 'ok', 'happy')`);
56
+ await db.run(`CREATE TABLE pgdb_test."enumArrayTable"(m pgdb_test.mood[] NULL)`);
57
+ await db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values (ARRAY['sad'::pgdb_test.mood, 'happy'::pgdb_test.mood])`);
73
58
  }
74
- function testDbFreeConnections(db) {
75
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
76
- let dedicatedConnections = new Array(poolSize).fill(null);
77
- yield Promise.race([
78
- asyncWaitMs(1000),
79
- (() => tslib_1.__awaiter(this, void 0, void 0, function* () {
80
- for (let i = 0; i < dedicatedConnections.length; ++i) {
81
- dedicatedConnections[i] = yield db.dedicatedConnectionBegin();
82
- }
83
- }))()
84
- ]);
85
- if (dedicatedConnections.some(v => !v)) {
86
- return new Error('Some of the connections are not free!');
87
- }
88
- for (let conn of dedicatedConnections) {
89
- yield conn.dedicatedConnectionEnd();
90
- }
91
- return null;
92
- });
59
+ async function testDbFreeConnections(db) {
60
+ let dedicatedConnections = new Array(poolSize).fill(null);
61
+ await Promise.race([
62
+ asyncWaitMs(1000),
63
+ (async () => {
64
+ for (let i = 0; i < dedicatedConnections.length; ++i) {
65
+ dedicatedConnections[i] = await db.dedicatedConnectionBegin();
66
+ }
67
+ })()
68
+ ]);
69
+ if (dedicatedConnections.some(v => !v)) {
70
+ return new Error('Some of the connections are not free!');
71
+ }
72
+ for (let conn of dedicatedConnections) {
73
+ await conn.dedicatedConnectionEnd();
74
+ }
75
+ return;
93
76
  }
94
- function testInsertQuery(db) {
95
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
96
- let tableContents = yield db.query(`select * from pgdb_test.names`);
97
- if (tableContents.length != 2) {
98
- return new Error('Simple query fails');
99
- }
100
- let callbackCounter1 = 0;
101
- yield db.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => {
102
- ++callbackCounter1;
103
- });
104
- if (callbackCounter1 != 2) {
105
- return new Error('Query with cursor callback fails');
106
- }
107
- let callbackCounter2 = 0;
108
- let stream = yield db.queryAsStream(`select * from pgdb_test.names`);
109
- yield new Promise((resolve, reject) => {
110
- stream.on("data", (data) => {
111
- ++callbackCounter2;
112
- });
113
- stream.on('error', reject);
114
- stream.on('close', resolve);
77
+ async function testInsertQuery(db) {
78
+ let tableContents = await db.query(`select * from pgdb_test.names`);
79
+ if (tableContents.length != 2) {
80
+ return new Error('Simple query fails');
81
+ }
82
+ let callbackCounter1 = 0;
83
+ await db.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => {
84
+ ++callbackCounter1;
85
+ });
86
+ if (callbackCounter1 != 2) {
87
+ return new Error('Query with cursor callback fails');
88
+ }
89
+ let callbackCounter2 = 0;
90
+ let stream = await db.queryAsStream(`select * from pgdb_test.names`);
91
+ await new Promise((resolve, reject) => {
92
+ stream.on("data", (data) => {
93
+ ++callbackCounter2;
115
94
  });
116
- if (callbackCounter2 != 2) {
117
- return new Error('Query as stream fails');
118
- }
119
- return null;
95
+ stream.on('error', reject);
96
+ stream.on('close', resolve);
120
97
  });
98
+ if (callbackCounter2 != 2) {
99
+ return new Error('Query as stream fails');
100
+ }
101
+ return;
121
102
  }
122
- function testNotificationSystem(db) {
123
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
124
- let result;
125
- yield db.listen('testChannel', (data) => { result = data.payload; });
126
- yield db.notify('testChannel', 'newData');
127
- yield asyncWaitMs(1000);
128
- if (result != 'newData') {
129
- return new Error('Notification not working...');
130
- }
131
- yield db.unlisten('testChannel');
132
- });
103
+ async function testNotificationSystem(db) {
104
+ let result;
105
+ await db.listen('testChannel', (data) => { result = data.payload; });
106
+ await db.notify('testChannel', 'newData');
107
+ await asyncWaitMs(1000);
108
+ if (result != 'newData') {
109
+ return new Error('Notification not working...');
110
+ }
111
+ await db.unlisten('testChannel');
133
112
  }
134
- function testDbUsability(db) {
135
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
136
- try {
137
- console.log('TestSchemaInit');
138
- yield testSchemaInit(db);
139
- console.log('TestFreeConnections');
140
- let error = yield testDbFreeConnections(db);
141
- if (!error) {
142
- console.log('TestInsertQueries');
143
- error = yield testInsertQuery(db);
144
- }
145
- if (!error) {
146
- console.log('TestNotifications');
147
- error = yield testNotificationSystem(db);
148
- }
149
- yield testSchemaClear(db);
150
- return error;
113
+ async function testDbUsability(db) {
114
+ try {
115
+ console.log('TestSchemaInit');
116
+ await testSchemaInit(db);
117
+ console.log('TestFreeConnections');
118
+ let error = await testDbFreeConnections(db);
119
+ if (!error) {
120
+ console.log('TestInsertQueries');
121
+ error = await testInsertQuery(db);
151
122
  }
152
- catch (e) {
153
- return e;
123
+ if (!error) {
124
+ console.log('TestNotifications');
125
+ error = await testNotificationSystem(db);
154
126
  }
155
- });
127
+ await testSchemaClear(db);
128
+ return error;
129
+ }
130
+ catch (e) {
131
+ return e;
132
+ }
156
133
  }
157
- function runTestInternal(db, test) {
158
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
159
- let callCounter = 0;
160
- let errorResult = null;
161
- try {
162
- yield test.fn(db, (value) => {
163
- ++callCounter;
164
- if (!value && !errorResult) {
165
- errorResult = new Error(`Error in test at the ${callCounter}. call.`);
166
- }
167
- });
168
- }
169
- catch (err) {
170
- if (!errorResult) {
171
- errorResult = err;
134
+ async function runTestInternal(db, test) {
135
+ let callCounter = 0;
136
+ let errorResult;
137
+ try {
138
+ await test.fn(db, (value) => {
139
+ ++callCounter;
140
+ if (!value && !errorResult) {
141
+ errorResult = new Error(`Error in test at the ${callCounter}. call.`);
172
142
  }
143
+ });
144
+ }
145
+ catch (err) {
146
+ if (!errorResult) {
147
+ errorResult = err;
173
148
  }
174
- yield postgresOn();
175
- if (!errorResult && !test.skipTestDb) {
176
- errorResult = yield testDbUsability(db);
177
- }
178
- return errorResult;
179
- });
149
+ }
150
+ await postgresOn();
151
+ if (!errorResult && !test.skipTestDb) {
152
+ errorResult = await testDbUsability(db);
153
+ }
154
+ return errorResult;
180
155
  }
181
156
  let actTestCounter = 0;
182
157
  let errorMessages = [];
183
- function runTest(allTestCount, test) {
184
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
185
- ++actTestCounter;
186
- console.log('====================================================================================');
187
- console.log(`${actTestCounter}/${allTestCount} Test starting: "${test.name}"`);
188
- console.log('====================================================================================');
189
- yield postgresOn();
190
- let db = yield pgDb_1.PgDb.connect({
191
- poolSize,
192
- logger: {
193
- log: console.log,
194
- error: console.error
195
- }
196
- });
197
- yield testSchemaInit(db);
198
- let error = yield runTestInternal(db, test);
199
- if (error) {
200
- errorMessages.push({ testName: test.name, err: error });
158
+ async function runTest(allTestCount, test) {
159
+ ++actTestCounter;
160
+ console.log('====================================================================================');
161
+ console.log(`${actTestCounter}/${allTestCount} Test starting: "${test.name}"`);
162
+ console.log('====================================================================================');
163
+ await postgresOn();
164
+ let db = await PgDb.connect({
165
+ poolSize,
166
+ logger: {
167
+ log: console.log,
168
+ error: console.error
201
169
  }
202
- yield db.close();
203
- console.log('====================================================================================');
204
- if (error) {
205
- console.log(`${actTestCounter}/${allTestCount} Test errored: "${test.name}"`);
206
- }
207
- else {
208
- console.log(`${actTestCounter}/${allTestCount} Test passed: "${test.name}"`);
209
- }
210
- console.log('====================================================================================');
211
170
  });
171
+ await testSchemaInit(db);
172
+ let error = await runTestInternal(db, test);
173
+ if (error) {
174
+ errorMessages.push({ testName: test.name, err: error });
175
+ }
176
+ await db.close();
177
+ console.log('====================================================================================');
178
+ if (error) {
179
+ console.log(`${actTestCounter}/${allTestCount} Test errored: "${test.name}"`);
180
+ }
181
+ else {
182
+ console.log(`${actTestCounter}/${allTestCount} Test passed: "${test.name}"`);
183
+ }
184
+ console.log('====================================================================================');
212
185
  }
213
186
  let newConnectionTests = [
214
187
  {
215
188
  name: 'simple query 1',
216
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
189
+ fn: async (db, isTrue) => {
217
190
  let stageCounter = 0;
218
- yield postgresOff();
191
+ await postgresOff();
219
192
  try {
220
- yield db.query(`select * from pgdb_test.names`);
193
+ await db.query(`select * from pgdb_test.names`);
221
194
  isTrue(false);
222
195
  }
223
196
  catch (e) {
224
197
  ++stageCounter;
225
198
  }
226
199
  try {
227
- yield db.query(`select * from pgdb_test.names`);
200
+ await db.query(`select * from pgdb_test.names`);
228
201
  isTrue(false);
229
202
  }
230
203
  catch (e) {
231
204
  ++stageCounter;
232
205
  }
233
206
  isTrue(stageCounter == 2);
234
- })
207
+ }
235
208
  },
236
209
  {
237
210
  name: 'simple query 2',
238
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
211
+ fn: async (db, isTrue) => {
239
212
  let stageCounter = 0;
240
- yield postgresOff();
213
+ await postgresOff();
241
214
  try {
242
- yield db.query(`select * from pgdb_test."enumArrayTable"`);
215
+ await db.query(`select * from pgdb_test."enumArrayTable"`);
243
216
  isTrue(false);
244
217
  }
245
218
  catch (e) {
246
219
  ++stageCounter;
247
220
  }
248
221
  try {
249
- yield db.query(`select * from pgdb_test."enumArrayTable"`);
222
+ await db.query(`select * from pgdb_test."enumArrayTable"`);
250
223
  isTrue(false);
251
224
  }
252
225
  catch (e) {
253
226
  ++stageCounter;
254
227
  }
255
228
  isTrue(stageCounter == 2);
256
- })
229
+ }
257
230
  },
258
231
  {
259
232
  name: 'queryWithCallback 1 - postgresOff before call',
260
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
233
+ fn: async (db, isTrue) => {
261
234
  let stageCounter = 0;
262
- yield postgresOff();
235
+ await postgresOff();
263
236
  try {
264
- yield db.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, () => {
237
+ await db.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, () => {
265
238
  isTrue(false);
266
239
  });
267
240
  isTrue(false);
@@ -270,18 +243,18 @@ let newConnectionTests = [
270
243
  ++stageCounter;
271
244
  }
272
245
  isTrue(stageCounter == 1);
273
- })
246
+ }
274
247
  },
275
248
  {
276
249
  name: 'queryWithCallback 2 - postgresOff between calls',
277
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
250
+ fn: async (db, isTrue) => {
278
251
  let stageCounter = 0;
279
252
  let params = new Array(2000).fill(null).map((v, i) => `'Smith${i}'`).map(v => `(${v})`).join(', ');
280
- yield db.run(`INSERT INTO pgdb_test.names(name) values ${params}`);
253
+ await db.run(`INSERT INTO pgdb_test.names(name) values ${params}`);
281
254
  let i = 0;
282
- let fn1 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
255
+ let fn1 = async () => {
283
256
  try {
284
- yield db.queryWithOnCursorCallback('select * from pgdb_test.names', {}, {}, (data) => {
257
+ await db.queryWithOnCursorCallback('select * from pgdb_test.names', {}, {}, (data) => {
285
258
  syncWaitMs(20);
286
259
  ++i;
287
260
  if (i % 10 == 0) {
@@ -293,27 +266,27 @@ let newConnectionTests = [
293
266
  catch (e) {
294
267
  ++stageCounter;
295
268
  }
296
- });
297
- let fn2 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
269
+ };
270
+ let fn2 = async () => {
298
271
  console.log('Wait before postgres off...');
299
- yield asyncWaitMs(100);
300
- yield postgresOff();
301
- });
302
- yield Promise.all([fn1(), fn2()]);
272
+ await asyncWaitMs(100);
273
+ await postgresOff();
274
+ };
275
+ await Promise.all([fn1(), fn2()]);
303
276
  isTrue(i > 0 && i < 2000);
304
277
  isTrue(stageCounter == 1);
305
- }),
278
+ },
306
279
  },
307
280
  {
308
281
  name: 'queryWithCallback 3 - postgresOff between calls, unknown oid',
309
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
282
+ fn: async (db, isTrue) => {
310
283
  let stageCounter = 0;
311
284
  let params = new Array(2000).fill(null).map((v) => `ARRAY['sad'::pgdb_test.mood, 'happy'::pgdb_test.mood]`).map(v => `(${v})`).join(', ');
312
- yield db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values ${params}`);
285
+ await db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values ${params}`);
313
286
  let i = 0;
314
- let fn1 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
287
+ let fn1 = async () => {
315
288
  try {
316
- yield db.queryWithOnCursorCallback('select * from pgdb_test."enumArrayTable"', {}, {}, (data) => {
289
+ await db.queryWithOnCursorCallback('select * from pgdb_test."enumArrayTable"', {}, {}, (data) => {
317
290
  syncWaitMs(20);
318
291
  ++i;
319
292
  if (i % 10 == 0) {
@@ -325,39 +298,39 @@ let newConnectionTests = [
325
298
  catch (e) {
326
299
  ++stageCounter;
327
300
  }
328
- });
329
- let fn2 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
301
+ };
302
+ let fn2 = async () => {
330
303
  console.log('Wait before postgres off...');
331
- yield asyncWaitMs(100);
332
- yield postgresOff();
333
- });
334
- yield Promise.all([fn1(), fn2()]);
304
+ await asyncWaitMs(100);
305
+ await postgresOff();
306
+ };
307
+ await Promise.all([fn1(), fn2()]);
335
308
  isTrue(i > 0 && i < 2000);
336
309
  isTrue(stageCounter == 1);
337
- }),
310
+ },
338
311
  },
339
312
  {
340
313
  name: 'queryAsStream 1 - postgresOff before call',
341
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
314
+ fn: async (db, isTrue) => {
342
315
  let stageCounter = 0;
343
- yield postgresOff();
316
+ await postgresOff();
344
317
  try {
345
- let stream = yield db.queryAsStream(`select * from pgdb_test.names`);
318
+ let stream = await db.queryAsStream(`select * from pgdb_test.names`);
346
319
  isTrue(false);
347
320
  }
348
321
  catch (e) {
349
322
  ++stageCounter;
350
323
  }
351
324
  isTrue(stageCounter == 1);
352
- })
325
+ }
353
326
  },
354
327
  {
355
328
  name: 'queryAsStream 2 - postgresOff between calls',
356
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
329
+ fn: async (db, isTrue) => {
357
330
  let stageCounter = 0;
358
331
  let params = new Array(2000).fill(null).map((v, i) => `'Smith${i}'`).map(v => `(${v})`).join(', ');
359
- yield db.run(`INSERT INTO pgdb_test.names(name) values ${params}`);
360
- let stream = yield db.queryAsStream('select * from pgdb_test.names');
332
+ await db.run(`INSERT INTO pgdb_test.names(name) values ${params}`);
333
+ let stream = await db.queryAsStream('select * from pgdb_test.names');
361
334
  let i = 0;
362
335
  let promise1 = new Promise((resolve, reject) => {
363
336
  stream.on("data", (data) => {
@@ -373,12 +346,12 @@ let newConnectionTests = [
373
346
  });
374
347
  stream.on('close', resolve);
375
348
  });
376
- let fn2 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
377
- yield asyncWaitMs(100);
378
- yield postgresOff();
379
- });
349
+ let fn2 = async () => {
350
+ await asyncWaitMs(100);
351
+ await postgresOff();
352
+ };
380
353
  try {
381
- yield Promise.all([promise1, fn2()]);
354
+ await Promise.all([promise1, fn2()]);
382
355
  isTrue(false);
383
356
  }
384
357
  catch (e) {
@@ -386,15 +359,15 @@ let newConnectionTests = [
386
359
  }
387
360
  isTrue(i > 0 && i < 2000);
388
361
  isTrue(stageCounter == 2);
389
- })
362
+ }
390
363
  },
391
364
  {
392
365
  name: 'queryAsStream 3 - postgresOff between calls, unknown oid',
393
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
366
+ fn: async (db, isTrue) => {
394
367
  let stageCounter = 0;
395
368
  let params = new Array(2000).fill(null).map((v) => `ARRAY['sad'::pgdb_test.mood, 'happy'::pgdb_test.mood]`).map(v => `(${v})`).join(', ');
396
- yield db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values ${params}`);
397
- let stream = yield db.queryAsStream('select * from pgdb_test."enumArrayTable"');
369
+ await db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values ${params}`);
370
+ let stream = await db.queryAsStream('select * from pgdb_test."enumArrayTable"');
398
371
  let i = 0;
399
372
  let promise1 = new Promise((resolve, reject) => {
400
373
  stream.on("data", (data) => {
@@ -410,12 +383,12 @@ let newConnectionTests = [
410
383
  });
411
384
  stream.on('close', resolve);
412
385
  });
413
- let fn2 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
414
- yield asyncWaitMs(100);
415
- yield postgresOff();
416
- });
386
+ let fn2 = async () => {
387
+ await asyncWaitMs(100);
388
+ await postgresOff();
389
+ };
417
390
  try {
418
- yield Promise.all([promise1, fn2()]);
391
+ await Promise.all([promise1, fn2()]);
419
392
  isTrue(false);
420
393
  }
421
394
  catch (e) {
@@ -423,393 +396,393 @@ let newConnectionTests = [
423
396
  }
424
397
  isTrue(i == 0);
425
398
  isTrue(stageCounter == 2);
426
- yield postgresOff();
427
- })
399
+ await postgresOff();
400
+ }
428
401
  },
429
402
  ];
430
403
  let dedicatedConnection_SimpleQueryTests = [
431
404
  {
432
405
  name: 'dedicated connection - empty 1',
433
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
406
+ fn: async (db, isTrue) => {
434
407
  let stageCounter = 0;
435
- yield postgresOff();
408
+ await postgresOff();
436
409
  try {
437
- let db0 = yield db.dedicatedConnectionBegin();
410
+ let db0 = await db.dedicatedConnectionBegin();
438
411
  isTrue(false);
439
412
  }
440
413
  catch (e) {
441
414
  ++stageCounter;
442
415
  }
443
416
  isTrue(stageCounter == 1);
444
- })
417
+ }
445
418
  },
446
419
  {
447
420
  name: 'dedicated connection - empty 2',
448
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
421
+ fn: async (db, isTrue) => {
449
422
  let stageCounter = 0;
450
- let db0 = yield db.dedicatedConnectionBegin();
451
- yield postgresOff();
423
+ let db0 = await db.dedicatedConnectionBegin();
424
+ await postgresOff();
452
425
  try {
453
- yield db0.dedicatedConnectionEnd();
426
+ await db0.dedicatedConnectionEnd();
454
427
  ++stageCounter;
455
428
  }
456
429
  catch (e) {
457
430
  isTrue(false);
458
431
  }
459
432
  isTrue(stageCounter == 1);
460
- })
433
+ }
461
434
  },
462
435
  {
463
436
  name: 'dedicated connection - simple query 1',
464
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
437
+ fn: async (db, isTrue) => {
465
438
  let stageCounter = 0;
466
- let db0 = yield db.dedicatedConnectionBegin();
467
- yield postgresOff();
439
+ let db0 = await db.dedicatedConnectionBegin();
440
+ await postgresOff();
468
441
  try {
469
- yield db0.query(`select * from pgdb_test.names`);
442
+ await db0.query(`select * from pgdb_test.names`);
470
443
  isTrue(false);
471
444
  }
472
445
  catch (e) {
473
446
  ++stageCounter;
474
447
  }
475
448
  isTrue(stageCounter == 1);
476
- })
449
+ }
477
450
  },
478
451
  {
479
452
  name: 'dedicated connection - simple query 2',
480
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
453
+ fn: async (db, isTrue) => {
481
454
  let stageCounter = 0;
482
- let db0 = yield db.dedicatedConnectionBegin();
483
- yield postgresOff();
455
+ let db0 = await db.dedicatedConnectionBegin();
456
+ await postgresOff();
484
457
  try {
485
- yield db0.query(`select * from pgdb_test.names`);
458
+ await db0.query(`select * from pgdb_test.names`);
486
459
  isTrue(false);
487
460
  }
488
461
  catch (e) {
489
462
  ++stageCounter;
490
463
  }
491
464
  try {
492
- yield db0.dedicatedConnectionEnd();
465
+ await db0.dedicatedConnectionEnd();
493
466
  ++stageCounter;
494
467
  }
495
468
  catch (e) {
496
469
  isTrue(false);
497
470
  }
498
471
  isTrue(stageCounter == 2);
499
- })
472
+ }
500
473
  },
501
474
  {
502
475
  name: 'dedicated connection - simple query 3',
503
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
476
+ fn: async (db, isTrue) => {
504
477
  let stageCounter = 0;
505
- let db0 = yield db.dedicatedConnectionBegin();
506
- yield db0.run(`truncate pgdb_test.names`);
507
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
508
- yield postgresOff();
478
+ let db0 = await db.dedicatedConnectionBegin();
479
+ await db0.run(`truncate pgdb_test.names`);
480
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
481
+ await postgresOff();
509
482
  try {
510
- yield db0.dedicatedConnectionEnd();
483
+ await db0.dedicatedConnectionEnd();
511
484
  ++stageCounter;
512
485
  }
513
486
  catch (e) {
514
487
  isTrue(false);
515
488
  }
516
- yield postgresOn();
517
- let result = yield db.query(`select * from pgdb_test.names`);
489
+ await postgresOn();
490
+ let result = await db.query(`select * from pgdb_test.names`);
518
491
  isTrue(result[0].name == 'Morgo');
519
492
  isTrue(stageCounter == 1);
520
- })
493
+ }
521
494
  },
522
495
  {
523
496
  name: 'dedicated connection - simple query 4',
524
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
497
+ fn: async (db, isTrue) => {
525
498
  let stageCounter = 0;
526
- let db0 = yield db.dedicatedConnectionBegin();
527
- yield db0.run(`truncate pgdb_test.names`);
528
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
529
- yield postgresOff();
499
+ let db0 = await db.dedicatedConnectionBegin();
500
+ await db0.run(`truncate pgdb_test.names`);
501
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
502
+ await postgresOff();
530
503
  try {
531
- yield db0.query(`select * from pgdb_test.names`);
504
+ await db0.query(`select * from pgdb_test.names`);
532
505
  isTrue(false);
533
506
  }
534
507
  catch (e) {
535
508
  ++stageCounter;
536
509
  }
537
- yield postgresOn();
538
- let result = yield db.query(`select * from pgdb_test.names`);
510
+ await postgresOn();
511
+ let result = await db.query(`select * from pgdb_test.names`);
539
512
  isTrue(result[0].name == 'Morgo');
540
513
  isTrue(stageCounter == 1);
541
- })
514
+ }
542
515
  },
543
516
  {
544
517
  name: 'dedicated connection - simple query 5',
545
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
518
+ fn: async (db, isTrue) => {
546
519
  let stageCounter = 0;
547
- let db0 = yield db.dedicatedConnectionBegin();
548
- yield db0.run(`truncate pgdb_test.names`);
549
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
550
- yield postgresOff();
520
+ let db0 = await db.dedicatedConnectionBegin();
521
+ await db0.run(`truncate pgdb_test.names`);
522
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
523
+ await postgresOff();
551
524
  try {
552
- yield db0.query(`select * from pgdb_test.names`);
525
+ await db0.query(`select * from pgdb_test.names`);
553
526
  isTrue(false);
554
527
  }
555
528
  catch (e) {
556
529
  ++stageCounter;
557
530
  }
558
531
  try {
559
- yield db0.dedicatedConnectionEnd();
532
+ await db0.dedicatedConnectionEnd();
560
533
  ++stageCounter;
561
534
  }
562
535
  catch (e) {
563
536
  isTrue(false);
564
537
  }
565
- yield postgresOn();
566
- let result = yield db.query(`select * from pgdb_test.names`);
538
+ await postgresOn();
539
+ let result = await db.query(`select * from pgdb_test.names`);
567
540
  isTrue(result[0].name == 'Morgo');
568
541
  isTrue(stageCounter == 2);
569
- })
542
+ }
570
543
  },
571
544
  {
572
545
  name: 'dedicated connection - simple query 6',
573
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
546
+ fn: async (db, isTrue) => {
574
547
  let stageCounter = 0;
575
- let db0 = yield db.dedicatedConnectionBegin();
576
- yield db0.run(`truncate pgdb_test.names`);
577
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
578
- yield postgresOff();
548
+ let db0 = await db.dedicatedConnectionBegin();
549
+ await db0.run(`truncate pgdb_test.names`);
550
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
551
+ await postgresOff();
579
552
  try {
580
- yield db0.query(`select * from pgdb_test.names`);
553
+ await db0.query(`select * from pgdb_test.names`);
581
554
  isTrue(false);
582
555
  }
583
556
  catch (e) {
584
557
  ++stageCounter;
585
558
  }
586
- yield postgresOn();
559
+ await postgresOn();
587
560
  try {
588
- yield db0.dedicatedConnectionEnd();
561
+ await db0.dedicatedConnectionEnd();
589
562
  ++stageCounter;
590
563
  }
591
564
  catch (e) {
592
565
  isTrue(false);
593
566
  }
594
- let result = yield db.query(`select * from pgdb_test.names`);
567
+ let result = await db.query(`select * from pgdb_test.names`);
595
568
  isTrue(result[0].name == 'Morgo');
596
569
  isTrue(stageCounter == 2);
597
- })
570
+ }
598
571
  },
599
572
  {
600
573
  name: 'transaction - simple query 7',
601
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
574
+ fn: async (db, isTrue) => {
602
575
  let stageCounter = 0;
603
- yield db.run(`truncate pgdb_test.names`);
604
- let db0 = yield db.transactionBegin();
605
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
606
- yield postgresOff();
576
+ await db.run(`truncate pgdb_test.names`);
577
+ let db0 = await db.transactionBegin();
578
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
579
+ await postgresOff();
607
580
  try {
608
- yield db0.query(`select * from pgdb_test.names`);
581
+ await db0.query(`select * from pgdb_test.names`);
609
582
  isTrue(false);
610
583
  }
611
584
  catch (e) {
612
585
  ++stageCounter;
613
586
  }
614
- yield postgresOn();
615
- let result = yield db.query(`select * from pgdb_test.names`);
587
+ await postgresOn();
588
+ let result = await db.query(`select * from pgdb_test.names`);
616
589
  isTrue(result.length == 0);
617
590
  isTrue(stageCounter == 1);
618
- })
591
+ }
619
592
  },
620
593
  {
621
594
  name: 'transaction - simple query 8',
622
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
595
+ fn: async (db, isTrue) => {
623
596
  let stageCounter = 0;
624
- yield db.run(`truncate pgdb_test.names`);
625
- let db0 = yield db.transactionBegin();
626
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
627
- yield postgresOff();
597
+ await db.run(`truncate pgdb_test.names`);
598
+ let db0 = await db.transactionBegin();
599
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
600
+ await postgresOff();
628
601
  try {
629
- yield db0.query(`select * from pgdb_test.names`);
602
+ await db0.query(`select * from pgdb_test.names`);
630
603
  isTrue(false);
631
604
  }
632
605
  catch (e) {
633
606
  ++stageCounter;
634
607
  }
635
- yield postgresOn();
608
+ await postgresOn();
636
609
  try {
637
- yield db0.transactionCommit();
610
+ await db0.transactionCommit();
638
611
  isTrue(false);
639
612
  }
640
613
  catch (e) {
641
614
  ++stageCounter;
642
615
  }
643
- let result = yield db.query(`select * from pgdb_test.names`);
616
+ let result = await db.query(`select * from pgdb_test.names`);
644
617
  isTrue(result.length == 0);
645
618
  isTrue(stageCounter == 2);
646
- })
619
+ }
647
620
  },
648
621
  {
649
622
  name: 'transaction - simple query 9',
650
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
623
+ fn: async (db, isTrue) => {
651
624
  let stageCounter = 0;
652
- yield db.run(`truncate pgdb_test.names`);
653
- let db0 = yield db.transactionBegin();
654
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
655
- yield postgresOff();
625
+ await db.run(`truncate pgdb_test.names`);
626
+ let db0 = await db.transactionBegin();
627
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
628
+ await postgresOff();
656
629
  try {
657
- yield db0.query(`select * from pgdb_test.names`);
630
+ await db0.query(`select * from pgdb_test.names`);
658
631
  isTrue(false);
659
632
  }
660
633
  catch (e) {
661
634
  ++stageCounter;
662
635
  }
663
636
  try {
664
- yield db0.transactionCommit();
637
+ await db0.transactionCommit();
665
638
  isTrue(false);
666
639
  }
667
640
  catch (e) {
668
641
  ++stageCounter;
669
642
  }
670
- yield postgresOn();
671
- let result = yield db.query(`select * from pgdb_test.names`);
643
+ await postgresOn();
644
+ let result = await db.query(`select * from pgdb_test.names`);
672
645
  isTrue(result.length == 0);
673
646
  isTrue(stageCounter == 2);
674
- })
647
+ }
675
648
  },
676
649
  {
677
650
  name: 'transaction - simple query 10',
678
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
651
+ fn: async (db, isTrue) => {
679
652
  let stageCounter = 0;
680
- yield db.run(`truncate pgdb_test.names`);
681
- let db0 = yield db.transactionBegin();
682
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
683
- yield postgresOff();
653
+ await db.run(`truncate pgdb_test.names`);
654
+ let db0 = await db.transactionBegin();
655
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
656
+ await postgresOff();
684
657
  try {
685
- yield db0.query(`select * from pgdb_test.names`);
658
+ await db0.query(`select * from pgdb_test.names`);
686
659
  isTrue(false);
687
660
  }
688
661
  catch (e) {
689
662
  ++stageCounter;
690
663
  }
691
- yield postgresOn();
692
- let result = yield db.query(`select * from pgdb_test.names`);
664
+ await postgresOn();
665
+ let result = await db.query(`select * from pgdb_test.names`);
693
666
  isTrue(result.length == 0);
694
667
  isTrue(stageCounter == 1);
695
- })
668
+ }
696
669
  },
697
670
  {
698
671
  name: 'transaction - simple query 11',
699
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
672
+ fn: async (db, isTrue) => {
700
673
  let stageCounter = 0;
701
- yield db.run(`truncate pgdb_test.names`);
702
- let db0 = yield db.transactionBegin();
703
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
704
- yield postgresOff();
674
+ await db.run(`truncate pgdb_test.names`);
675
+ let db0 = await db.transactionBegin();
676
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
677
+ await postgresOff();
705
678
  try {
706
- yield db0.transactionCommit();
679
+ await db0.transactionCommit();
707
680
  isTrue(false);
708
681
  }
709
682
  catch (e) {
710
683
  ++stageCounter;
711
684
  }
712
- yield postgresOn();
713
- let result = yield db.query(`select * from pgdb_test.names`);
685
+ await postgresOn();
686
+ let result = await db.query(`select * from pgdb_test.names`);
714
687
  isTrue(result.length == 0);
715
688
  isTrue(stageCounter == 1);
716
- })
689
+ }
717
690
  },
718
691
  {
719
692
  name: 'transaction - rollback 1',
720
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
693
+ fn: async (db, isTrue) => {
721
694
  let stageCounter = 0;
722
- yield db.run(`truncate pgdb_test.names`);
723
- let db0 = yield db.transactionBegin();
724
- yield postgresOff();
695
+ await db.run(`truncate pgdb_test.names`);
696
+ let db0 = await db.transactionBegin();
697
+ await postgresOff();
725
698
  try {
726
- yield db0.transactionRollback();
699
+ await db0.transactionRollback();
727
700
  isTrue(false);
728
701
  }
729
702
  catch (e) {
730
703
  ++stageCounter;
731
704
  }
732
705
  isTrue(stageCounter == 1);
733
- })
706
+ }
734
707
  },
735
708
  {
736
709
  name: 'transaction - rollback 2',
737
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
710
+ fn: async (db, isTrue) => {
738
711
  let stageCounter = 0;
739
- yield db.run(`truncate pgdb_test.names`);
740
- let db0 = yield db.transactionBegin();
741
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
742
- yield postgresOff();
712
+ await db.run(`truncate pgdb_test.names`);
713
+ let db0 = await db.transactionBegin();
714
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
715
+ await postgresOff();
743
716
  try {
744
- yield db0.transactionRollback();
717
+ await db0.transactionRollback();
745
718
  isTrue(false);
746
719
  }
747
720
  catch (e) {
748
721
  ++stageCounter;
749
722
  }
750
723
  isTrue(stageCounter == 1);
751
- })
724
+ }
752
725
  },
753
726
  {
754
727
  name: 'transaction - rollback 3',
755
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
728
+ fn: async (db, isTrue) => {
756
729
  let stageCounter = 0;
757
- yield db.run(`truncate pgdb_test.names`);
758
- let db0 = yield db.transactionBegin();
759
- yield postgresOff();
730
+ await db.run(`truncate pgdb_test.names`);
731
+ let db0 = await db.transactionBegin();
732
+ await postgresOff();
760
733
  try {
761
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
734
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
762
735
  isTrue(false);
763
736
  }
764
737
  catch (e) {
765
738
  ++stageCounter;
766
739
  }
767
740
  try {
768
- yield db0.transactionRollback();
741
+ await db0.transactionRollback();
769
742
  isTrue(false);
770
743
  }
771
744
  catch (e) {
772
745
  ++stageCounter;
773
746
  }
774
747
  isTrue(stageCounter == 2);
775
- })
748
+ }
776
749
  },
777
750
  {
778
751
  name: 'transaction - rollback 4',
779
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
752
+ fn: async (db, isTrue) => {
780
753
  let stageCounter = 0;
781
- yield db.run(`truncate pgdb_test.names`);
782
- let db0 = yield db.transactionBegin();
783
- yield postgresOff();
754
+ await db.run(`truncate pgdb_test.names`);
755
+ let db0 = await db.transactionBegin();
756
+ await postgresOff();
784
757
  try {
785
- yield db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
758
+ await db0.run(`insert into pgdb_test.names (name) values ('Morgo')`);
786
759
  isTrue(false);
787
760
  }
788
761
  catch (e) {
789
762
  ++stageCounter;
790
763
  }
791
- yield postgresOn();
764
+ await postgresOn();
792
765
  try {
793
- yield db0.transactionRollback();
766
+ await db0.transactionRollback();
794
767
  isTrue(false);
795
768
  }
796
769
  catch (e) {
797
770
  ++stageCounter;
798
771
  }
799
772
  isTrue(stageCounter == 2);
800
- })
773
+ }
801
774
  }
802
775
  ];
803
776
  let dedicatedConnection_StreamQueryTests = [
804
777
  {
805
778
  name: 'dedicated connection queryWithCallback - 1',
806
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
779
+ fn: async (db, isTrue) => {
807
780
  let stageCounter = 0;
808
- let db0 = yield db.dedicatedConnectionBegin();
809
- yield postgresOff();
781
+ let db0 = await db.dedicatedConnectionBegin();
782
+ await postgresOff();
810
783
  let i = 0;
811
784
  try {
812
- yield db0.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => { ++i; });
785
+ await db0.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => { ++i; });
813
786
  isTrue(false);
814
787
  }
815
788
  catch (e) {
@@ -817,24 +790,24 @@ let dedicatedConnection_StreamQueryTests = [
817
790
  }
818
791
  isTrue(i == 0);
819
792
  isTrue(stageCounter == 1);
820
- })
793
+ }
821
794
  },
822
795
  {
823
796
  name: 'dedicated connection queryWithCallback - 1',
824
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
797
+ fn: async (db, isTrue) => {
825
798
  let stageCounter = 0;
826
- let db0 = yield db.dedicatedConnectionBegin();
827
- yield postgresOff();
799
+ let db0 = await db.dedicatedConnectionBegin();
800
+ await postgresOff();
828
801
  let i = 0;
829
802
  try {
830
- yield db0.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => { ++i; });
803
+ await db0.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => { ++i; });
831
804
  isTrue(false);
832
805
  }
833
806
  catch (e) {
834
807
  ++stageCounter;
835
808
  }
836
809
  try {
837
- yield db0.dedicatedConnectionEnd();
810
+ await db0.dedicatedConnectionEnd();
838
811
  ++stageCounter;
839
812
  }
840
813
  catch (e) {
@@ -842,16 +815,16 @@ let dedicatedConnection_StreamQueryTests = [
842
815
  }
843
816
  isTrue(i == 0);
844
817
  isTrue(stageCounter == 2);
845
- })
818
+ }
846
819
  },
847
820
  {
848
821
  name: 'dedicated connection queryWithCallback - 3',
849
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
822
+ fn: async (db, isTrue) => {
850
823
  let stageCounter = 0;
851
- let db0 = yield db.dedicatedConnectionBegin();
852
- yield postgresOff();
824
+ let db0 = await db.dedicatedConnectionBegin();
825
+ await postgresOff();
853
826
  try {
854
- yield db0.query(`select * from pgdb_test.names`);
827
+ await db0.query(`select * from pgdb_test.names`);
855
828
  isTrue(false);
856
829
  }
857
830
  catch (e) {
@@ -859,7 +832,7 @@ let dedicatedConnection_StreamQueryTests = [
859
832
  }
860
833
  let i = 0;
861
834
  try {
862
- yield db0.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => { ++i; });
835
+ await db0.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => { ++i; });
863
836
  isTrue(false);
864
837
  }
865
838
  catch (e) {
@@ -867,19 +840,19 @@ let dedicatedConnection_StreamQueryTests = [
867
840
  }
868
841
  isTrue(i == 0);
869
842
  isTrue(stageCounter == 2);
870
- })
843
+ }
871
844
  },
872
845
  {
873
846
  name: 'dedicated connection queryWithCallback 4 - postgresOff between calls',
874
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
847
+ fn: async (db, isTrue) => {
875
848
  let stageCounter = 0;
876
849
  let params = new Array(2000).fill(null).map((v, i) => `'Smith${i}'`).map(v => `(${v})`).join(', ');
877
- yield db.run(`INSERT INTO pgdb_test.names(name) values ${params}`);
878
- let db0 = yield db.dedicatedConnectionBegin();
850
+ await db.run(`INSERT INTO pgdb_test.names(name) values ${params}`);
851
+ let db0 = await db.dedicatedConnectionBegin();
879
852
  let i = 0;
880
- let fn1 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
853
+ let fn1 = async () => {
881
854
  try {
882
- yield db0.queryWithOnCursorCallback('select * from pgdb_test.names', {}, {}, (data) => {
855
+ await db0.queryWithOnCursorCallback('select * from pgdb_test.names', {}, {}, (data) => {
883
856
  syncWaitMs(20);
884
857
  ++i;
885
858
  if (i % 10 == 0) {
@@ -891,28 +864,28 @@ let dedicatedConnection_StreamQueryTests = [
891
864
  catch (e) {
892
865
  ++stageCounter;
893
866
  }
894
- });
895
- let fn2 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
867
+ };
868
+ let fn2 = async () => {
896
869
  console.log('Wait before postgres off...');
897
- yield asyncWaitMs(100);
898
- yield postgresOff();
899
- });
900
- yield Promise.all([fn1(), fn2()]);
870
+ await asyncWaitMs(100);
871
+ await postgresOff();
872
+ };
873
+ await Promise.all([fn1(), fn2()]);
901
874
  isTrue(i > 0 && i < 2000);
902
875
  isTrue(stageCounter == 1);
903
- }),
876
+ },
904
877
  },
905
878
  {
906
879
  name: 'dedicated connection queryWithCallback 5 - postgresOff between calls, unknown oid',
907
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
880
+ fn: async (db, isTrue) => {
908
881
  let stageCounter = 0;
909
882
  let params = new Array(2000).fill(null).map((v) => `ARRAY['sad'::pgdb_test.mood, 'happy'::pgdb_test.mood]`).map(v => `(${v})`).join(', ');
910
- yield db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values ${params}`);
911
- let db0 = yield db.dedicatedConnectionBegin();
883
+ await db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values ${params}`);
884
+ let db0 = await db.dedicatedConnectionBegin();
912
885
  let i = 0;
913
- let fn1 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
886
+ let fn1 = async () => {
914
887
  try {
915
- yield db0.queryWithOnCursorCallback('select * from pgdb_test."enumArrayTable"', {}, {}, (data) => {
888
+ await db0.queryWithOnCursorCallback('select * from pgdb_test."enumArrayTable"', {}, {}, (data) => {
916
889
  syncWaitMs(20);
917
890
  ++i;
918
891
  if (i % 10 == 0) {
@@ -924,33 +897,33 @@ let dedicatedConnection_StreamQueryTests = [
924
897
  catch (e) {
925
898
  ++stageCounter;
926
899
  }
927
- });
928
- let fn2 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
900
+ };
901
+ let fn2 = async () => {
929
902
  console.log('Wait before postgres off...');
930
- yield asyncWaitMs(100);
931
- yield postgresOff();
932
- });
933
- yield Promise.all([fn1(), fn2()]);
903
+ await asyncWaitMs(100);
904
+ await postgresOff();
905
+ };
906
+ await Promise.all([fn1(), fn2()]);
934
907
  isTrue(i > 0 && i < 2000);
935
908
  isTrue(stageCounter == 1);
936
- }),
909
+ },
937
910
  },
938
911
  {
939
912
  name: 'dedicated connection queryAsStream - 1',
940
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
913
+ fn: async (db, isTrue) => {
941
914
  let stageCounter = 0;
942
- let db0 = yield db.dedicatedConnectionBegin();
943
- yield postgresOff();
915
+ let db0 = await db.dedicatedConnectionBegin();
916
+ await postgresOff();
944
917
  let stream;
945
918
  try {
946
- stream = yield db0.queryAsStream(`select * from pgdb_test.names`);
919
+ stream = await db0.queryAsStream(`select * from pgdb_test.names`);
947
920
  ++stageCounter;
948
921
  }
949
922
  catch (e) {
950
923
  isTrue(false);
951
924
  }
952
925
  try {
953
- yield new Promise((resolve, reject) => {
926
+ await new Promise((resolve, reject) => {
954
927
  stream.on("data", (data) => {
955
928
  isTrue(false);
956
929
  });
@@ -966,24 +939,24 @@ let dedicatedConnection_StreamQueryTests = [
966
939
  ++stageCounter;
967
940
  }
968
941
  isTrue(stageCounter == 3);
969
- })
942
+ }
970
943
  },
971
944
  {
972
945
  name: 'dedicated connection queryAsStream - 2',
973
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
946
+ fn: async (db, isTrue) => {
974
947
  let stageCounter = 0;
975
- let db0 = yield db.dedicatedConnectionBegin();
976
- yield postgresOff();
948
+ let db0 = await db.dedicatedConnectionBegin();
949
+ await postgresOff();
977
950
  let stream;
978
951
  try {
979
- stream = yield db0.queryAsStream(`select * from pgdb_test.names`);
952
+ stream = await db0.queryAsStream(`select * from pgdb_test.names`);
980
953
  ++stageCounter;
981
954
  }
982
955
  catch (e) {
983
956
  isTrue(false);
984
957
  }
985
958
  try {
986
- yield new Promise((resolve, reject) => {
959
+ await new Promise((resolve, reject) => {
987
960
  stream.on("data", (data) => {
988
961
  isTrue(false);
989
962
  });
@@ -999,23 +972,23 @@ let dedicatedConnection_StreamQueryTests = [
999
972
  ++stageCounter;
1000
973
  }
1001
974
  try {
1002
- yield db0.dedicatedConnectionEnd();
975
+ await db0.dedicatedConnectionEnd();
1003
976
  ++stageCounter;
1004
977
  }
1005
978
  catch (e) {
1006
979
  isTrue(false);
1007
980
  }
1008
981
  isTrue(stageCounter == 4);
1009
- })
982
+ }
1010
983
  },
1011
984
  {
1012
985
  name: 'dedicated connection queryAsStream - 3',
1013
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
986
+ fn: async (db, isTrue) => {
1014
987
  let stageCounter = 0;
1015
- let db0 = yield db.dedicatedConnectionBegin();
1016
- yield postgresOff();
988
+ let db0 = await db.dedicatedConnectionBegin();
989
+ await postgresOff();
1017
990
  try {
1018
- yield db0.query(`select * from pgdb_test.names`);
991
+ await db0.query(`select * from pgdb_test.names`);
1019
992
  isTrue(false);
1020
993
  }
1021
994
  catch (e) {
@@ -1023,14 +996,14 @@ let dedicatedConnection_StreamQueryTests = [
1023
996
  }
1024
997
  let stream;
1025
998
  try {
1026
- stream = yield db0.queryAsStream(`select * from pgdb_test.names`);
999
+ stream = await db0.queryAsStream(`select * from pgdb_test.names`);
1027
1000
  ++stageCounter;
1028
1001
  }
1029
1002
  catch (e) {
1030
1003
  isTrue(false);
1031
1004
  }
1032
1005
  try {
1033
- yield new Promise((resolve, reject) => {
1006
+ await new Promise((resolve, reject) => {
1034
1007
  stream.on("data", (data) => {
1035
1008
  isTrue(false);
1036
1009
  });
@@ -1046,16 +1019,16 @@ let dedicatedConnection_StreamQueryTests = [
1046
1019
  ++stageCounter;
1047
1020
  }
1048
1021
  isTrue(stageCounter == 4);
1049
- })
1022
+ }
1050
1023
  },
1051
1024
  {
1052
1025
  name: 'dedicated connection queryAsStream 4 - postgresOff between calls',
1053
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1026
+ fn: async (db, isTrue) => {
1054
1027
  let stageCounter = 0;
1055
1028
  let params = new Array(2000).fill(null).map((v, i) => `'Smith${i}'`).map(v => `(${v})`).join(', ');
1056
- yield db.run(`INSERT INTO pgdb_test.names(name) values ${params}`);
1057
- let db0 = yield db.dedicatedConnectionBegin();
1058
- let stream = yield db0.queryAsStream('select * from pgdb_test.names');
1029
+ await db.run(`INSERT INTO pgdb_test.names(name) values ${params}`);
1030
+ let db0 = await db.dedicatedConnectionBegin();
1031
+ let stream = await db0.queryAsStream('select * from pgdb_test.names');
1059
1032
  let i = 0;
1060
1033
  let promise1 = new Promise((resolve, reject) => {
1061
1034
  stream.on("data", (data) => {
@@ -1071,12 +1044,12 @@ let dedicatedConnection_StreamQueryTests = [
1071
1044
  });
1072
1045
  stream.on('close', resolve);
1073
1046
  });
1074
- let fn2 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1075
- yield asyncWaitMs(100);
1076
- yield postgresOff();
1077
- });
1047
+ let fn2 = async () => {
1048
+ await asyncWaitMs(100);
1049
+ await postgresOff();
1050
+ };
1078
1051
  try {
1079
- yield Promise.all([promise1, fn2()]);
1052
+ await Promise.all([promise1, fn2()]);
1080
1053
  isTrue(false);
1081
1054
  }
1082
1055
  catch (e) {
@@ -1084,16 +1057,16 @@ let dedicatedConnection_StreamQueryTests = [
1084
1057
  }
1085
1058
  isTrue(i > 0 && i < 2000);
1086
1059
  isTrue(stageCounter == 2);
1087
- }),
1060
+ },
1088
1061
  },
1089
1062
  {
1090
1063
  name: 'dedicated connection queryAsStream 5 - postgresOff between calls, unknown oid',
1091
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1064
+ fn: async (db, isTrue) => {
1092
1065
  let stageCounter = 0;
1093
1066
  let params = new Array(2000).fill(null).map((v) => `ARRAY['sad'::pgdb_test.mood, 'happy'::pgdb_test.mood]`).map(v => `(${v})`).join(', ');
1094
- yield db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values ${params}`);
1095
- let db0 = yield db.dedicatedConnectionBegin();
1096
- let stream = yield db0.queryAsStream('select * from pgdb_test."enumArrayTable"');
1067
+ await db.run(`INSERT INTO pgdb_test."enumArrayTable"(m) values ${params}`);
1068
+ let db0 = await db.dedicatedConnectionBegin();
1069
+ let stream = await db0.queryAsStream('select * from pgdb_test."enumArrayTable"');
1097
1070
  let i = 0;
1098
1071
  let promise1 = new Promise((resolve, reject) => {
1099
1072
  stream.on("data", (data) => {
@@ -1109,12 +1082,12 @@ let dedicatedConnection_StreamQueryTests = [
1109
1082
  });
1110
1083
  stream.on('close', resolve);
1111
1084
  });
1112
- let fn2 = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1113
- yield asyncWaitMs(100);
1114
- yield postgresOff();
1115
- });
1085
+ let fn2 = async () => {
1086
+ await asyncWaitMs(100);
1087
+ await postgresOff();
1088
+ };
1116
1089
  try {
1117
- yield Promise.all([promise1, fn2()]);
1090
+ await Promise.all([promise1, fn2()]);
1118
1091
  isTrue(false);
1119
1092
  }
1120
1093
  catch (e) {
@@ -1122,71 +1095,71 @@ let dedicatedConnection_StreamQueryTests = [
1122
1095
  }
1123
1096
  isTrue(i == 0);
1124
1097
  isTrue(stageCounter == 2);
1125
- yield postgresOff();
1126
- }),
1098
+ await postgresOff();
1099
+ },
1127
1100
  }
1128
1101
  ];
1129
1102
  let postgresRestartTests = [
1130
1103
  {
1131
1104
  name: 'postgres restart 1',
1132
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1105
+ fn: async (db, isTrue) => {
1133
1106
  let stageCounter = 0;
1134
- let db0 = yield db.dedicatedConnectionBegin();
1135
- yield postgresOff();
1136
- yield postgresOn();
1107
+ let db0 = await db.dedicatedConnectionBegin();
1108
+ await postgresOff();
1109
+ await postgresOn();
1137
1110
  try {
1138
- yield db0.dedicatedConnectionEnd();
1111
+ await db0.dedicatedConnectionEnd();
1139
1112
  ++stageCounter;
1140
1113
  }
1141
1114
  catch (e) {
1142
1115
  isTrue(false);
1143
1116
  }
1144
1117
  isTrue(stageCounter == 1);
1145
- })
1118
+ }
1146
1119
  },
1147
1120
  {
1148
1121
  name: 'postgres restart 2',
1149
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1122
+ fn: async (db, isTrue) => {
1150
1123
  let stageCounter = 0;
1151
- let db0 = yield db.transactionBegin();
1152
- yield postgresOff();
1153
- yield postgresOn();
1124
+ let db0 = await db.transactionBegin();
1125
+ await postgresOff();
1126
+ await postgresOn();
1154
1127
  try {
1155
- yield db0.transactionRollback();
1128
+ await db0.transactionRollback();
1156
1129
  isTrue(false);
1157
1130
  }
1158
1131
  catch (e) {
1159
1132
  ++stageCounter;
1160
1133
  }
1161
1134
  isTrue(stageCounter == 1);
1162
- })
1135
+ }
1163
1136
  },
1164
1137
  {
1165
1138
  name: 'postgres restart 3',
1166
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1139
+ fn: async (db, isTrue) => {
1167
1140
  let stageCounter = 0;
1168
- let db0 = yield db.dedicatedConnectionBegin();
1169
- yield postgresOff();
1170
- yield postgresOn();
1141
+ let db0 = await db.dedicatedConnectionBegin();
1142
+ await postgresOff();
1143
+ await postgresOn();
1171
1144
  try {
1172
- let result = yield db0.query(`select * from pgdb_test.names`);
1145
+ let result = await db0.query(`select * from pgdb_test.names`);
1173
1146
  isTrue(false);
1174
1147
  }
1175
1148
  catch (e) {
1176
1149
  ++stageCounter;
1177
1150
  }
1178
1151
  isTrue(stageCounter == 1);
1179
- })
1152
+ }
1180
1153
  },
1181
1154
  {
1182
1155
  name: 'postgres restart 4',
1183
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1156
+ fn: async (db, isTrue) => {
1184
1157
  let stageCounter = 0;
1185
- let db0 = yield db.dedicatedConnectionBegin();
1186
- yield postgresOff();
1187
- yield postgresOn();
1158
+ let db0 = await db.dedicatedConnectionBegin();
1159
+ await postgresOff();
1160
+ await postgresOn();
1188
1161
  try {
1189
- let result = yield db0.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => {
1162
+ let result = await db0.queryWithOnCursorCallback(`select * from pgdb_test.names`, {}, {}, (data) => {
1190
1163
  isTrue(false);
1191
1164
  });
1192
1165
  isTrue(false);
@@ -1195,25 +1168,25 @@ let postgresRestartTests = [
1195
1168
  ++stageCounter;
1196
1169
  }
1197
1170
  isTrue(stageCounter == 1);
1198
- })
1171
+ }
1199
1172
  },
1200
1173
  {
1201
1174
  name: 'postgres restart 5',
1202
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1175
+ fn: async (db, isTrue) => {
1203
1176
  let stageCounter = 0;
1204
- let db0 = yield db.dedicatedConnectionBegin();
1205
- yield postgresOff();
1206
- yield postgresOn();
1177
+ let db0 = await db.dedicatedConnectionBegin();
1178
+ await postgresOff();
1179
+ await postgresOn();
1207
1180
  let stream;
1208
1181
  try {
1209
- stream = yield db0.queryAsStream(`select * from pgdb_test.names`);
1182
+ stream = await db0.queryAsStream(`select * from pgdb_test.names`);
1210
1183
  ++stageCounter;
1211
1184
  }
1212
1185
  catch (e) {
1213
1186
  isTrue(false);
1214
1187
  }
1215
1188
  try {
1216
- yield new Promise((resolve, reject) => {
1189
+ await new Promise((resolve, reject) => {
1217
1190
  stream.on("data", (data) => {
1218
1191
  isTrue(false);
1219
1192
  });
@@ -1229,304 +1202,300 @@ let postgresRestartTests = [
1229
1202
  ++stageCounter;
1230
1203
  }
1231
1204
  isTrue(stageCounter == 3);
1232
- })
1205
+ }
1233
1206
  },
1234
1207
  ];
1235
1208
  let postgresEndTests = [
1236
1209
  {
1237
1210
  name: 'postgres end 1',
1238
1211
  skipTestDb: true,
1239
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1212
+ fn: async (db, isTrue) => {
1240
1213
  let stageCounter = 0;
1241
- let db0 = yield db.dedicatedConnectionBegin();
1242
- yield postgresOff();
1214
+ let db0 = await db.dedicatedConnectionBegin();
1215
+ await postgresOff();
1243
1216
  try {
1244
- yield db.close();
1217
+ await db.close();
1245
1218
  ++stageCounter;
1246
1219
  }
1247
1220
  catch (e) {
1248
1221
  isTrue(false);
1249
1222
  }
1250
1223
  isTrue(stageCounter == 1);
1251
- })
1224
+ }
1252
1225
  }
1253
1226
  ];
1254
1227
  let notifyTests = [
1255
1228
  {
1256
1229
  name: 'notification 1',
1257
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1230
+ fn: async (db, isTrue) => {
1258
1231
  let stageCounter = 0;
1259
- yield postgresOff();
1232
+ await postgresOff();
1260
1233
  try {
1261
- yield db.listen('newChannel', (notif) => { });
1234
+ await db.listen('newChannel', (notif) => { });
1262
1235
  isTrue(false);
1263
1236
  }
1264
1237
  catch (e) {
1265
1238
  ++stageCounter;
1266
1239
  }
1267
1240
  isTrue(stageCounter == 1);
1268
- })
1241
+ }
1269
1242
  },
1270
1243
  {
1271
1244
  name: 'notification 2',
1272
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1273
- yield db.listen('newChannel', (notif) => { });
1274
- yield postgresOff();
1275
- yield postgresOn();
1276
- yield db.unlisten('newChannel');
1277
- })
1245
+ fn: async (db, isTrue) => {
1246
+ await db.listen('newChannel', (notif) => { });
1247
+ await postgresOff();
1248
+ await postgresOn();
1249
+ await db.unlisten('newChannel');
1250
+ }
1278
1251
  },
1279
1252
  {
1280
1253
  name: 'notification 3',
1281
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1254
+ fn: async (db, isTrue) => {
1282
1255
  let result;
1283
- yield db.listen('newChannel', (notif) => { result = notif.payload; });
1284
- yield postgresOff();
1285
- yield postgresOn();
1286
- yield db.notify('newChannel', 'newValue');
1287
- yield asyncWaitMs(1000);
1256
+ await db.listen('newChannel', (notif) => { result = notif.payload; });
1257
+ await postgresOff();
1258
+ await postgresOn();
1259
+ await db.notify('newChannel', 'newValue');
1260
+ await asyncWaitMs(1000);
1288
1261
  isTrue(result == 'newValue');
1289
- yield db.unlisten('newChannel');
1290
- })
1262
+ await db.unlisten('newChannel');
1263
+ }
1291
1264
  },
1292
1265
  {
1293
1266
  name: 'notification 4',
1294
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1267
+ fn: async (db, isTrue) => {
1295
1268
  let result;
1296
- yield db.listen('newChannel', (notif) => { result = notif.payload; });
1297
- yield postgresOff();
1298
- yield postgresOn();
1299
- yield db.run(`notify "newChannel", 'newValue'`);
1300
- yield asyncWaitMs(1000);
1269
+ await db.listen('newChannel', (notif) => { result = notif.payload; });
1270
+ await postgresOff();
1271
+ await postgresOn();
1272
+ await db.run(`notify "newChannel", 'newValue'`);
1273
+ await asyncWaitMs(1000);
1301
1274
  isTrue(result == 'newValue');
1302
- yield db.unlisten('newChannel');
1303
- })
1275
+ await db.unlisten('newChannel');
1276
+ }
1304
1277
  },
1305
1278
  {
1306
1279
  name: 'notification 5',
1307
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1280
+ fn: async (db, isTrue) => {
1308
1281
  let result;
1309
- yield db.listen('newChannel', (notif) => { result = notif.payload; });
1310
- yield postgresOff();
1311
- yield postgresOn();
1312
- let db0 = yield db.dedicatedConnectionBegin();
1313
- yield db0.run(`notify "newChannel", 'newValue'`);
1314
- yield asyncWaitMs(1000);
1282
+ await db.listen('newChannel', (notif) => { result = notif.payload; });
1283
+ await postgresOff();
1284
+ await postgresOn();
1285
+ let db0 = await db.dedicatedConnectionBegin();
1286
+ await db0.run(`notify "newChannel", 'newValue'`);
1287
+ await asyncWaitMs(1000);
1315
1288
  isTrue(result == 'newValue');
1316
- yield db.unlisten('newChannel');
1317
- yield db0.dedicatedConnectionEnd();
1318
- })
1289
+ await db.unlisten('newChannel');
1290
+ await db0.dedicatedConnectionEnd();
1291
+ }
1319
1292
  },
1320
1293
  {
1321
1294
  name: 'notification 6',
1322
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1295
+ fn: async (db, isTrue) => {
1323
1296
  let i = 0;
1324
1297
  let fn1 = (notif) => { i += +notif.payload; };
1325
1298
  let fn2 = (notif) => { i += 2 * (+notif.payload); };
1326
- yield db.listen('newChannel', fn1);
1327
- yield postgresOff();
1328
- yield db.listen('newChannel', fn2);
1329
- yield postgresOn();
1330
- yield db.notify('newChannel', '1');
1331
- yield asyncWaitMs(1000);
1299
+ await db.listen('newChannel', fn1);
1300
+ await postgresOff();
1301
+ await db.listen('newChannel', fn2);
1302
+ await postgresOn();
1303
+ await db.notify('newChannel', '1');
1304
+ await asyncWaitMs(1000);
1332
1305
  isTrue(i == 3);
1333
- yield db.unlisten('newChannel');
1334
- })
1306
+ await db.unlisten('newChannel');
1307
+ }
1335
1308
  },
1336
1309
  {
1337
1310
  name: 'notification 7',
1338
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1311
+ fn: async (db, isTrue) => {
1339
1312
  let i = 0;
1340
1313
  let fn1 = (notif) => { i += +notif.payload; };
1341
1314
  let fn2 = (notif) => { i += 2 * (+notif.payload); };
1342
- yield db.listen('newChannel', fn1);
1343
- yield postgresOff();
1344
- yield db.listen('newChannel', fn2);
1345
- yield db.unlisten('newChannel', fn1);
1346
- yield postgresOn();
1347
- yield db.notify('newChannel', '1');
1348
- yield asyncWaitMs(1000);
1315
+ await db.listen('newChannel', fn1);
1316
+ await postgresOff();
1317
+ await db.listen('newChannel', fn2);
1318
+ await db.unlisten('newChannel', fn1);
1319
+ await postgresOn();
1320
+ await db.notify('newChannel', '1');
1321
+ await asyncWaitMs(1000);
1349
1322
  isTrue(i == 2);
1350
- yield db.unlisten('newChannel');
1351
- })
1323
+ await db.unlisten('newChannel');
1324
+ }
1352
1325
  },
1353
1326
  {
1354
1327
  name: 'notification 8',
1355
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1328
+ fn: async (db, isTrue) => {
1356
1329
  let i = 0;
1357
1330
  let j = 0;
1358
1331
  let fn1 = (notif) => { i += +notif.payload; };
1359
1332
  let fn2 = (notif) => { j += +notif.payload; };
1360
- yield db.listen('newChannel', fn1);
1361
- yield postgresOff();
1333
+ await db.listen('newChannel', fn1);
1334
+ await postgresOff();
1362
1335
  try {
1363
- yield db.listen('newChannel2', fn2);
1336
+ await db.listen('newChannel2', fn2);
1364
1337
  isTrue(false);
1365
1338
  }
1366
1339
  catch (e) {
1367
1340
  }
1368
- yield postgresOn();
1369
- yield db.notify('newChannel', '1');
1370
- yield db.notify('newChannel2', '1');
1371
- yield asyncWaitMs(1000);
1341
+ await postgresOn();
1342
+ await db.notify('newChannel', '1');
1343
+ await db.notify('newChannel2', '1');
1344
+ await asyncWaitMs(1000);
1372
1345
  isTrue(i == 1);
1373
1346
  isTrue(j == 0);
1374
- yield db.unlisten('newChannel');
1375
- })
1347
+ await db.unlisten('newChannel');
1348
+ }
1376
1349
  },
1377
1350
  {
1378
1351
  name: 'notification 9',
1379
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1352
+ fn: async (db, isTrue) => {
1380
1353
  let i = 0;
1381
1354
  let fn1 = (notif) => { i += +notif.payload; };
1382
- yield db.listen('newChannel', fn1);
1383
- yield postgresOff();
1355
+ await db.listen('newChannel', fn1);
1356
+ await postgresOff();
1384
1357
  try {
1385
- yield db.unlisten('newChannel', fn1);
1358
+ await db.unlisten('newChannel', fn1);
1386
1359
  isTrue(false);
1387
1360
  }
1388
1361
  catch (e) {
1389
1362
  }
1390
- yield postgresOn();
1391
- yield db.notify('newChannel', '1');
1392
- yield asyncWaitMs(1000);
1363
+ await postgresOn();
1364
+ await db.notify('newChannel', '1');
1365
+ await asyncWaitMs(1000);
1393
1366
  isTrue(i == 1);
1394
- yield db.unlisten('newChannel');
1395
- })
1367
+ await db.unlisten('newChannel');
1368
+ }
1396
1369
  },
1397
1370
  {
1398
1371
  name: 'notification 10',
1399
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1372
+ fn: async (db, isTrue) => {
1400
1373
  let i = 0;
1401
1374
  let fn1 = (notif) => { i += +notif.payload; };
1402
- yield db.listen('newChannel', fn1);
1403
- yield postgresOff();
1375
+ await db.listen('newChannel', fn1);
1376
+ await postgresOff();
1404
1377
  try {
1405
- yield db.unlisten('newChannel');
1378
+ await db.unlisten('newChannel');
1406
1379
  isTrue(false);
1407
1380
  }
1408
1381
  catch (e) {
1409
1382
  }
1410
- yield postgresOn();
1411
- yield db.notify('newChannel', '1');
1412
- yield asyncWaitMs(1000);
1383
+ await postgresOn();
1384
+ await db.notify('newChannel', '1');
1385
+ await asyncWaitMs(1000);
1413
1386
  isTrue(i == 1);
1414
- yield db.unlisten('newChannel');
1415
- })
1387
+ await db.unlisten('newChannel');
1388
+ }
1416
1389
  },
1417
1390
  {
1418
1391
  name: 'notification 11 - automatic notification restart...',
1419
- fn: (db, isTrue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1392
+ fn: async (db, isTrue) => {
1420
1393
  let i = 0;
1421
1394
  let fn1 = (notif) => { i += +notif.payload; };
1422
- yield db.listen('newChannel', fn1);
1423
- yield postgresOff();
1424
- yield postgresOn();
1425
- yield asyncWaitMs(3000);
1426
- let db2 = yield pgDb_1.PgDb.connect({});
1427
- yield db2.notify('newChannel', '1');
1428
- yield db2.close();
1429
- yield asyncWaitMs(1000);
1395
+ await db.listen('newChannel', fn1);
1396
+ await postgresOff();
1397
+ await postgresOn();
1398
+ await asyncWaitMs(3000);
1399
+ let db2 = await PgDb.connect({});
1400
+ await db2.notify('newChannel', '1');
1401
+ await db2.close();
1402
+ await asyncWaitMs(1000);
1430
1403
  isTrue(i == 1);
1431
- yield db.unlisten('newChannel');
1432
- })
1404
+ await db.unlisten('newChannel');
1405
+ }
1433
1406
  }
1434
1407
  ];
1435
- function testParams() {
1436
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
1437
- console.log('Start testing params');
1438
- let postgresOnCommandOk = true;
1439
- let postgresOffCommandOk = false;
1440
- let frameworkError = false;
1408
+ async function testParams() {
1409
+ console.log('Start testing params');
1410
+ let postgresOnCommandOk = true;
1411
+ let postgresOffCommandOk = false;
1412
+ let frameworkError = false;
1413
+ try {
1414
+ console.log('Postgres On test');
1415
+ await postgresOn();
1441
1416
  try {
1442
- console.log('Postgres On test');
1443
- yield postgresOn();
1444
- try {
1445
- let db = yield pgDb_1.PgDb.connect({});
1446
- }
1447
- catch (e) {
1448
- postgresOnCommandOk = false;
1449
- }
1450
- console.log('Postgres Off test');
1451
- yield postgresOff();
1452
- try {
1453
- let db = yield pgDb_1.PgDb.connect({});
1454
- }
1455
- catch (e) {
1456
- postgresOffCommandOk = postgresOnCommandOk;
1457
- }
1458
- console.log('Postgres On test');
1459
- yield postgresOn();
1460
- try {
1461
- let db = yield pgDb_1.PgDb.connect({});
1462
- }
1463
- catch (e) {
1464
- postgresOnCommandOk = false;
1465
- }
1417
+ let db = await PgDb.connect({});
1466
1418
  }
1467
1419
  catch (e) {
1468
- console.log('Unknown exception has found', e);
1469
- frameworkError = true;
1420
+ postgresOnCommandOk = false;
1470
1421
  }
1471
- if (!frameworkError) {
1472
- if (postgresOffCommandOk && postgresOnCommandOk) {
1473
- console.log('Postgres On/Off commands OK');
1474
- }
1475
- else {
1476
- if (!postgresOnCommandOk) {
1477
- console.log('Postgres On command NOT OK');
1478
- }
1479
- if (!postgresOffCommandOk) {
1480
- console.log('Postgres Off command NOT OK');
1481
- }
1482
- }
1422
+ console.log('Postgres Off test');
1423
+ await postgresOff();
1424
+ try {
1425
+ let db = await PgDb.connect({});
1483
1426
  }
1484
- console.log('Postgres On/Off test end');
1485
- });
1486
- }
1487
- function runTests() {
1488
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
1489
- console.log('Start tests');
1490
- let allTests = [
1491
- ...newConnectionTests,
1492
- ...dedicatedConnection_SimpleQueryTests,
1493
- ...dedicatedConnection_StreamQueryTests,
1494
- ...postgresRestartTests,
1495
- ...notifyTests,
1496
- ...postgresEndTests
1497
- ];
1498
- let testNamePrefix = '';
1427
+ catch (e) {
1428
+ postgresOffCommandOk = postgresOnCommandOk;
1429
+ }
1430
+ console.log('Postgres On test');
1431
+ await postgresOn();
1499
1432
  try {
1500
- if (testNamePrefix) {
1501
- allTests = allTests.filter(v => v.name.startsWith(testNamePrefix));
1502
- }
1503
- for (let test of allTests) {
1504
- yield runTest(allTests.length, test);
1433
+ let db = await PgDb.connect({});
1434
+ }
1435
+ catch (e) {
1436
+ postgresOnCommandOk = false;
1437
+ }
1438
+ }
1439
+ catch (e) {
1440
+ console.log('Unknown exception has found', e);
1441
+ frameworkError = true;
1442
+ }
1443
+ if (!frameworkError) {
1444
+ if (postgresOffCommandOk && postgresOnCommandOk) {
1445
+ console.log('Postgres On/Off commands OK');
1446
+ }
1447
+ else {
1448
+ if (!postgresOnCommandOk) {
1449
+ console.log('Postgres On command NOT OK');
1505
1450
  }
1506
- console.log('All tests: ', actTestCounter);
1507
- console.log(`Problematic tests: ${errorMessages.length}`);
1508
- for (let errorMessage of errorMessages) {
1509
- console.log(`Error in "${errorMessage.testName}"`);
1510
- console.log(errorMessage.err);
1451
+ if (!postgresOffCommandOk) {
1452
+ console.log('Postgres Off command NOT OK');
1511
1453
  }
1512
1454
  }
1513
- catch (e) {
1514
- console.log('Error has found in the test framework!');
1515
- console.log(e);
1455
+ }
1456
+ console.log('Postgres On/Off test end');
1457
+ }
1458
+ async function runTests() {
1459
+ console.log('Start tests');
1460
+ let allTests = [
1461
+ ...newConnectionTests,
1462
+ ...dedicatedConnection_SimpleQueryTests,
1463
+ ...dedicatedConnection_StreamQueryTests,
1464
+ ...postgresRestartTests,
1465
+ ...notifyTests,
1466
+ ...postgresEndTests
1467
+ ];
1468
+ let testNamePrefix = '';
1469
+ try {
1470
+ if (testNamePrefix) {
1471
+ allTests = allTests.filter(v => v.name.startsWith(testNamePrefix));
1516
1472
  }
1517
- console.log('All tests are finished');
1518
- });
1473
+ for (let test of allTests) {
1474
+ await runTest(allTests.length, test);
1475
+ }
1476
+ console.log('All tests: ', actTestCounter);
1477
+ console.log(`Problematic tests: ${errorMessages.length}`);
1478
+ for (let errorMessage of errorMessages) {
1479
+ console.log(`Error in "${errorMessage.testName}"`);
1480
+ console.log(errorMessage.err);
1481
+ }
1482
+ }
1483
+ catch (e) {
1484
+ console.log('Error has found in the test framework!');
1485
+ console.log(e);
1486
+ }
1487
+ console.log('All tests are finished');
1519
1488
  }
1520
- (() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
1489
+ (async () => {
1521
1490
  if (!argv.postgresOn || !argv.postgresOff) {
1522
1491
  console.log('postgresOn or postgresOff parameter is missing!');
1523
1492
  return;
1524
1493
  }
1525
1494
  if (argv.testParams) {
1526
- yield testParams();
1495
+ await testParams();
1527
1496
  }
1528
1497
  else {
1529
- yield runTests();
1498
+ await runTests();
1530
1499
  }
1531
- }))().catch(console.log);
1500
+ })().catch(console.log);
1532
1501
  //# sourceMappingURL=pgServiceRestartTest.js.map