2015-04-24 14:57:35 -04:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var parseConnection = require('../../lib/util/parse-connection')
|
|
|
|
var test = require('tape')
|
|
|
|
|
|
|
|
test('parses standard connections', function(t) {
|
|
|
|
t.plan(1)
|
|
|
|
t.deepEqual(parseConnection('postgres://username:pass@path.to.some-url:6000/testdb'), {
|
|
|
|
client: 'postgres',
|
|
|
|
connection: {
|
|
|
|
user: 'username',
|
|
|
|
password: 'pass',
|
|
|
|
host: 'path.to.some-url',
|
|
|
|
port: '6000',
|
|
|
|
database: 'testdb'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2016-06-06 22:19:24 -04:00
|
|
|
test('parses standard connections without password', function(t) {
|
|
|
|
t.plan(1)
|
|
|
|
t.deepEqual(parseConnection('mysql://username@path.to.some-url:3306/testdb'), {
|
|
|
|
client: 'mysql',
|
|
|
|
connection: {
|
|
|
|
user: 'username',
|
|
|
|
host: 'path.to.some-url',
|
|
|
|
port: '3306',
|
|
|
|
database: 'testdb'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2015-04-24 14:57:35 -04:00
|
|
|
|
2016-04-12 03:33:28 +04:00
|
|
|
test('parses mssql connections, aliasing host to server', function(t) {
|
|
|
|
t.plan(1)
|
|
|
|
var mssql = {
|
|
|
|
client: 'mssql',
|
|
|
|
connection: {
|
|
|
|
user: 'username',
|
|
|
|
password: 'pass',
|
|
|
|
server: 'path.to.some-url',
|
|
|
|
port: '6000',
|
|
|
|
database: 'testdb'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.deepEqual(parseConnection('mssql://username:pass@path.to.some-url:6000/testdb'), mssql)
|
|
|
|
})
|
|
|
|
|
2015-04-24 14:57:35 -04:00
|
|
|
test('assume a path is mysql', function(t) {
|
|
|
|
t.plan(1)
|
|
|
|
t.deepEqual(parseConnection('/path/to/file.db'), {
|
|
|
|
client: 'sqlite3',
|
|
|
|
connection: {
|
|
|
|
filename: '/path/to/file.db'
|
|
|
|
}
|
|
|
|
})
|
2015-04-24 15:20:35 -04:00
|
|
|
})
|
2015-06-01 07:39:57 -04:00
|
|
|
|
2015-06-01 07:55:04 -04:00
|
|
|
test('#852, ssl param with PG query string', function(t) {
|
2015-06-01 07:39:57 -04:00
|
|
|
t.plan(1)
|
|
|
|
t.deepEqual(parseConnection("postgres://user:password@host:0000/database?ssl=true").connection, {
|
|
|
|
host: "host",
|
|
|
|
port: "0000",
|
|
|
|
user: "user",
|
|
|
|
password: "password",
|
|
|
|
database: "database",
|
2016-03-08 08:41:13 +01:00
|
|
|
ssl: true
|
2015-06-01 07:39:57 -04:00
|
|
|
})
|
|
|
|
})
|
2018-05-18 05:12:15 -04:00
|
|
|
|
|
|
|
test('support postgresql connection protocol', function(t) {
|
|
|
|
t.plan(1)
|
|
|
|
t.deepEqual(parseConnection('postgresql://user:password@host:0000/database?ssl=true').connection, {
|
|
|
|
host: 'host',
|
|
|
|
port: '0000',
|
|
|
|
user: 'user',
|
|
|
|
password: 'password',
|
|
|
|
database: 'database',
|
|
|
|
ssl: true
|
|
|
|
})
|
|
|
|
})
|