@contember/database 1.2.0-alpha.14 → 1.2.0-alpha.16
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/dist/src/client/Connection.d.ts +3 -3
- package/dist/src/client/Connection.d.ts.map +1 -1
- package/dist/src/client/Connection.js +4 -6
- package/dist/src/client/Connection.js.map +1 -1
- package/dist/src/client/Pool.d.ts +3 -1
- package/dist/src/client/Pool.d.ts.map +1 -1
- package/dist/src/client/Pool.js +3 -0
- package/dist/src/client/Pool.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/createDatabaseIfNotExists.d.ts +1 -1
- package/dist/src/utils/createDatabaseIfNotExists.d.ts.map +1 -1
- package/dist/src/utils/createDatabaseIfNotExists.js +2 -2
- package/dist/src/utils/createDatabaseIfNotExists.js.map +1 -1
- package/dist/src/utils/retryTransaction.d.ts +1 -1
- package/dist/src/utils/retryTransaction.d.ts.map +1 -1
- package/dist/src/utils/retryTransaction.js +3 -5
- package/dist/src/utils/retryTransaction.js.map +1 -1
- package/dist/tests/cases/unit/createConnectionMockAlt.js +1 -1
- package/dist/tests/cases/unit/createConnectionMockAlt.js.map +1 -1
- package/dist/tests/cases/unit/pool.test.js +12 -0
- package/dist/tests/cases/unit/pool.test.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/client/Connection.ts +5 -5
- package/src/client/Pool.ts +6 -1
- package/src/utils/createDatabaseIfNotExists.ts +3 -3
- package/src/utils/retryTransaction.ts +3 -4
- package/tests/cases/unit/createConnectionMockAlt.ts +1 -1
- package/tests/cases/unit/pool.test.ts +12 -0
|
@@ -25,6 +25,7 @@ it('acquires and releases new connection from pool', async () => {
|
|
|
25
25
|
const logger = createPoolLogger()
|
|
26
26
|
const pool = new Pool(() => new PgClientMock() as unknown as PgClient, {
|
|
27
27
|
log: logger,
|
|
28
|
+
logError: () => null,
|
|
28
29
|
})
|
|
29
30
|
const connection = await pool.acquire()
|
|
30
31
|
await pool.release(connection)
|
|
@@ -46,6 +47,7 @@ it('disposes connection when maxIdle is reached', async () => {
|
|
|
46
47
|
const logger = createPoolLogger()
|
|
47
48
|
const pool = new Pool(() => new PgClientMock() as unknown as PgClient, {
|
|
48
49
|
log: logger,
|
|
50
|
+
logError: () => null,
|
|
49
51
|
maxIdle: 0,
|
|
50
52
|
})
|
|
51
53
|
const connection = await pool.acquire()
|
|
@@ -67,6 +69,7 @@ it('disposes connection after max uses', async () => {
|
|
|
67
69
|
const logger = createPoolLogger()
|
|
68
70
|
const pool = new Pool(() => new PgClientMock() as unknown as PgClient, {
|
|
69
71
|
log: logger,
|
|
72
|
+
logError: () => null,
|
|
70
73
|
maxUses: 1,
|
|
71
74
|
})
|
|
72
75
|
const connection = await pool.acquire()
|
|
@@ -89,6 +92,7 @@ it('disposes errored connection', async () => {
|
|
|
89
92
|
const logger = createPoolLogger()
|
|
90
93
|
const pool = new Pool(() => new PgClientMock() as unknown as PgClient, {
|
|
91
94
|
log: logger,
|
|
95
|
+
logError: () => null,
|
|
92
96
|
maxIdle: 0,
|
|
93
97
|
})
|
|
94
98
|
const connection = await pool.acquire()
|
|
@@ -114,6 +118,7 @@ it('time outs when waiting for a connection', async () => {
|
|
|
114
118
|
clientMock.connections.push(createSuccessfulPromise(5))
|
|
115
119
|
const pool = new Pool(() => clientMock as unknown as PgClient, {
|
|
116
120
|
log: logger,
|
|
121
|
+
logError: () => null,
|
|
117
122
|
acquireTimeoutMs: 2,
|
|
118
123
|
})
|
|
119
124
|
await expect(pool.acquire.bind(pool)).rejects.toThrowError('Failed to acquire a connection')
|
|
@@ -135,6 +140,7 @@ it('acquires idle connection from pool', async () => {
|
|
|
135
140
|
const logger = createPoolLogger()
|
|
136
141
|
const pool = new Pool(() => new PgClientMock() as unknown as PgClient, {
|
|
137
142
|
log: logger,
|
|
143
|
+
logError: () => null,
|
|
138
144
|
})
|
|
139
145
|
const connection = await pool.acquire()
|
|
140
146
|
await pool.release(connection)
|
|
@@ -154,6 +160,7 @@ it('acquires multiple new connections from pool', async () => {
|
|
|
154
160
|
const logger = createPoolLogger()
|
|
155
161
|
const pool = new Pool(() => new PgClientMock() as unknown as PgClient, {
|
|
156
162
|
log: logger,
|
|
163
|
+
logError: () => null,
|
|
157
164
|
})
|
|
158
165
|
const conn1 = await pool.acquire()
|
|
159
166
|
const conn2 = await pool.acquire()
|
|
@@ -184,6 +191,7 @@ it('releases idle connection', async () => {
|
|
|
184
191
|
const logger = createPoolLogger()
|
|
185
192
|
const pool = new Pool(() => new PgClientMock() as unknown as PgClient, {
|
|
186
193
|
log: logger,
|
|
194
|
+
logError: () => null,
|
|
187
195
|
idleTimeoutMs: 2,
|
|
188
196
|
})
|
|
189
197
|
const conn1 = await pool.acquire()
|
|
@@ -208,6 +216,7 @@ it('waits for idle connection when pool is full', async () => {
|
|
|
208
216
|
const pool = new Pool(() => new PgClientMock() as unknown as PgClient, {
|
|
209
217
|
maxConnections: 1,
|
|
210
218
|
log: logger,
|
|
219
|
+
logError: () => null,
|
|
211
220
|
})
|
|
212
221
|
const conn1 = await pool.acquire()
|
|
213
222
|
setTimeout(async () => {
|
|
@@ -241,6 +250,7 @@ it('tries to reconnect on recoverable error', async () => {
|
|
|
241
250
|
})
|
|
242
251
|
const pool = new Pool(() => pgClientMock as unknown as PgClient, {
|
|
243
252
|
log: logger,
|
|
253
|
+
logError: () => null,
|
|
244
254
|
})
|
|
245
255
|
pgClientMock.connections.push(createRecoverableErrorPromise(), createRecoverableErrorPromise())
|
|
246
256
|
await pool.acquire()
|
|
@@ -272,6 +282,7 @@ it('fails to reconnect on recoverable error', async () => {
|
|
|
272
282
|
})
|
|
273
283
|
const pool = new Pool(() => pgClientMock as unknown as PgClient, {
|
|
274
284
|
log: logger,
|
|
285
|
+
logError: () => null,
|
|
275
286
|
reconnectIntervalMs: 5,
|
|
276
287
|
acquireTimeoutMs: 10,
|
|
277
288
|
})
|
|
@@ -301,6 +312,7 @@ it('fails to reconnect on unrecoverable error', async () => {
|
|
|
301
312
|
})
|
|
302
313
|
const pool = new Pool(() => pgClientMock as unknown as PgClient, {
|
|
303
314
|
log: logger,
|
|
315
|
+
logError: () => null,
|
|
304
316
|
})
|
|
305
317
|
pool.on('error', () => {
|
|
306
318
|
|