2015-05-01 14:55:53 -04:00
|
|
|
'use strict';
|
2015-05-01 14:49:18 -04:00
|
|
|
|
|
|
|
var knex = require('../../lib/index');
|
|
|
|
var test = require('tape')
|
|
|
|
|
|
|
|
test('it should parse the connection string', function(t) {
|
|
|
|
t.plan(1)
|
|
|
|
var knexObj = knex({
|
|
|
|
client: 'mysql',
|
|
|
|
connection: "mysql://user:password@example.com/dbname"
|
|
|
|
})
|
2016-03-08 08:41:13 +01:00
|
|
|
t.deepEqual(knexObj.client.config.connection, {
|
|
|
|
database: 'dbname',
|
|
|
|
host: 'example.com',
|
|
|
|
password: 'password',
|
|
|
|
user: 'user'
|
2015-05-01 14:49:18 -04:00
|
|
|
})
|
|
|
|
knexObj.destroy()
|
2016-05-19 12:18:11 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
test('it should allow to use proprietary dialect', function(t) {
|
|
|
|
t.plan(2)
|
|
|
|
var Client = require('../../lib/dialects/mysql')
|
|
|
|
var knexObj = knex({
|
|
|
|
client: Client,
|
2016-05-19 13:32:07 +03:00
|
|
|
connection: {
|
|
|
|
database: 'dbname',
|
|
|
|
host: 'example.com',
|
|
|
|
password: 'password',
|
|
|
|
user: 'user'
|
|
|
|
}
|
2016-05-19 12:18:11 +03:00
|
|
|
})
|
|
|
|
t.ok(knexObj.client instanceof Client)
|
2016-05-19 13:32:07 +03:00
|
|
|
t.deepEqual(knexObj.client.config, {
|
2016-05-19 12:18:11 +03:00
|
|
|
client: Client,
|
2016-05-19 13:32:07 +03:00
|
|
|
connection: {
|
|
|
|
database: 'dbname',
|
|
|
|
host: 'example.com',
|
|
|
|
password: 'password',
|
|
|
|
user: 'user'
|
|
|
|
}
|
2016-05-19 12:18:11 +03:00
|
|
|
})
|
|
|
|
knexObj.destroy()
|
|
|
|
})
|
|
|
|
|
|
|
|
test('it should use knex suppoted dialect', function(t) {
|
|
|
|
t.plan(1)
|
|
|
|
var knexObj = knex({
|
|
|
|
client: 'postgres',
|
2016-05-19 13:32:07 +03:00
|
|
|
connection: {
|
|
|
|
database: 'dbname',
|
|
|
|
host: 'example.com',
|
|
|
|
password: 'password',
|
|
|
|
user: 'user'
|
|
|
|
}
|
2016-05-19 12:18:11 +03:00
|
|
|
})
|
2016-05-19 13:32:07 +03:00
|
|
|
t.deepEqual(knexObj.client.config, {
|
2016-05-19 12:18:11 +03:00
|
|
|
client: 'postgres',
|
2016-05-19 13:32:07 +03:00
|
|
|
connection: {
|
|
|
|
database: 'dbname',
|
|
|
|
host: 'example.com',
|
|
|
|
password: 'password',
|
|
|
|
user: 'user'
|
|
|
|
}
|
2016-05-19 12:18:11 +03:00
|
|
|
})
|
|
|
|
knexObj.destroy()
|
2016-09-13 08:19:47 -04:00
|
|
|
})
|