2019-10-06 20:21:32 +02:00
|
|
|
// global it, describe
|
2016-11-30 20:44:43 +13:00
|
|
|
|
|
|
|
'use strict';
|
2018-10-15 22:29:53 -04:00
|
|
|
const _ = require('lodash');
|
|
|
|
const expect = require('chai').expect;
|
|
|
|
const knex = require('../../../knex');
|
|
|
|
const config = require('../../knexfile');
|
|
|
|
const sinon = require('sinon');
|
2016-11-30 20:44:43 +13:00
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
describe('OracleDb externalAuth', function() {
|
2018-10-15 22:29:53 -04:00
|
|
|
const knexInstance = knex({
|
2017-04-28 11:47:24 +01:00
|
|
|
client: 'oracledb',
|
|
|
|
connection: {
|
2018-07-09 08:10:34 -04:00
|
|
|
user: 'user',
|
|
|
|
password: 'password',
|
|
|
|
connectString: 'connect-string',
|
|
|
|
externalAuth: true,
|
|
|
|
host: 'host',
|
|
|
|
database: 'database',
|
|
|
|
},
|
2017-04-28 11:47:24 +01:00
|
|
|
});
|
2018-10-15 22:29:53 -04:00
|
|
|
let spy;
|
2016-11-30 20:44:43 +13:00
|
|
|
|
2017-04-28 11:47:24 +01:00
|
|
|
before(function() {
|
2018-07-09 08:10:34 -04:00
|
|
|
spy = sinon.spy(knexInstance.client.driver, 'getConnection');
|
2017-04-28 11:47:24 +01:00
|
|
|
});
|
2016-11-30 20:44:43 +13:00
|
|
|
|
|
|
|
it('externalAuth and connectString should be sent to the getConnection', function() {
|
2018-10-15 22:29:53 -04:00
|
|
|
const connectionWithExternalAuth = {
|
2018-07-09 08:10:34 -04:00
|
|
|
connectString: 'connect-string',
|
|
|
|
externalAuth: true,
|
|
|
|
};
|
|
|
|
knexInstance.client
|
|
|
|
.acquireRawConnection()
|
|
|
|
.then(function(resolve) {}, function(reject) {});
|
|
|
|
expect(spy).to.have.callCount(1);
|
|
|
|
expect(spy).to.have.been.calledWith(connectionWithExternalAuth);
|
2016-11-30 20:44:43 +13:00
|
|
|
});
|
2017-04-28 11:47:24 +01:00
|
|
|
|
|
|
|
after(function() {
|
2018-02-01 23:46:12 +02:00
|
|
|
knexInstance.client.driver.getConnection.restore();
|
2017-04-28 11:47:24 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
describe('OracleDb parameters', function() {
|
2019-05-13 12:21:36 +03:00
|
|
|
describe('with fetchAsString parameter ', function() {
|
2018-10-15 22:29:53 -04:00
|
|
|
let knexClient;
|
2017-04-28 11:47:24 +01:00
|
|
|
|
|
|
|
before(function() {
|
2018-10-15 22:29:53 -04:00
|
|
|
const conf = _.clone(config.oracledb);
|
2018-07-09 08:10:34 -04:00
|
|
|
conf.fetchAsString = ['number', 'DATE', 'cLOb'];
|
2017-04-28 11:47:24 +01:00
|
|
|
knexClient = knex(conf);
|
|
|
|
return knexClient;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('on float', function() {
|
2018-07-09 08:10:34 -04:00
|
|
|
return knexClient
|
|
|
|
.raw('select 7.329 as "field" from dual')
|
|
|
|
.then(function(result) {
|
|
|
|
expect(result[0]).to.be.ok;
|
|
|
|
expect(result[0].field).to.be.a('string');
|
|
|
|
});
|
2017-04-28 11:47:24 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('on date', function() {
|
2018-07-09 08:10:34 -04:00
|
|
|
return knexClient
|
|
|
|
.raw('select CURRENT_DATE as "field" from dual')
|
|
|
|
.then(function(result) {
|
|
|
|
expect(result[0]).to.be.ok;
|
|
|
|
expect(result[0].field).to.be.a('string');
|
|
|
|
});
|
2017-04-28 11:47:24 +01:00
|
|
|
});
|
|
|
|
|
2019-10-15 09:23:07 +03:00
|
|
|
it('on clob', function() {
|
|
|
|
return knexClient
|
|
|
|
.raw('select TO_CLOB(\'LONG CONTENT\') as "field" from dual')
|
|
|
|
.then(function(result) {
|
|
|
|
expect(result[0]).to.be.ok;
|
|
|
|
expect(result[0].field).to.be.equal('LONG CONTENT');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-04-28 11:47:24 +01:00
|
|
|
after(function() {
|
|
|
|
return knexClient.destroy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-09 08:10:34 -04:00
|
|
|
describe('without fetchAsString parameter', function() {
|
2018-10-15 22:29:53 -04:00
|
|
|
let knexClient;
|
2017-04-28 11:47:24 +01:00
|
|
|
|
|
|
|
before(function() {
|
|
|
|
knexClient = knex(config.oracledb);
|
|
|
|
return knexClient;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('on float', function() {
|
2018-07-09 08:10:34 -04:00
|
|
|
return knexClient
|
|
|
|
.raw('select 7.329 as "field" from dual')
|
|
|
|
.then(function(result) {
|
|
|
|
expect(result[0]).to.be.ok;
|
|
|
|
expect(result[0].field).to.not.be.a('string');
|
|
|
|
});
|
2017-04-28 11:47:24 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('on date', function() {
|
2018-07-09 08:10:34 -04:00
|
|
|
return knexClient
|
|
|
|
.raw('select CURRENT_DATE as "field" from dual')
|
|
|
|
.then(function(result) {
|
|
|
|
expect(result[0]).to.be.ok;
|
|
|
|
expect(result[0].field).to.not.be.a('string');
|
|
|
|
});
|
2017-04-28 11:47:24 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function() {
|
|
|
|
return knexClient.destroy();
|
|
|
|
});
|
|
|
|
});
|
2016-11-30 20:44:43 +13:00
|
|
|
});
|