Skip to content

Commit 7633b37

Browse files
committed
Added test for duplicate connection name
1 parent 79174c4 commit 7633b37

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"homepage": "https://github.com/cemremengu/fastify-oracle#readme",
2828
"devDependencies": {
2929
"coveralls": "^3.0.2",
30-
"fastify": "^1.1.0",
30+
"fastify": "^1.11.1",
3131
"pre-commit": "^1.2.2",
3232
"snazzy": "^8.0.0",
3333
"standard": "^12.0.1",

test/pool.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const test = require('tap').test
44
const plugin = require('../plugin')
5+
const Fastify = require('fastify')
56

67
test('creates pool from config', (t) => {
78
t.plan(6)
@@ -88,3 +89,23 @@ test('creates named pool from config', (t) => {
8889
.catch(t.threw)
8990
})
9091
})
92+
93+
test('duplicate connection names should throw', (t) => {
94+
t.plan(1)
95+
96+
const fastify = Fastify()
97+
98+
const opts = {
99+
user: 'travis',
100+
password: 'travis',
101+
connectString: 'localhost/xe'
102+
}
103+
104+
fastify
105+
.register(plugin, { pool: opts, name: 'testdb' })
106+
.register(plugin, { pool: opts, name: 'testdb' })
107+
108+
fastify.ready(err => {
109+
t.is(err.message, 'Connection name has already been registered: testdb')
110+
})
111+
})

0 commit comments

Comments
 (0)