2015-07-20 12:42:12 +08:00
|
|
|
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* You may not use the identified files except in compliance with the Apache
|
|
|
|
* License, Version 2.0 (the "License.")
|
|
|
|
*
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
*
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
|
|
|
|
* See LICENSE.md for relevant licenses.
|
|
|
|
*
|
|
|
|
* NAME
|
|
|
|
* 22. dataTypeChar.js
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Testing Oracle data type support - CHAR.
|
|
|
|
*
|
|
|
|
* NUMBERING RULE
|
|
|
|
* Test numbers follow this numbering rule:
|
|
|
|
* 1 - 20 are reserved for basic functional tests
|
|
|
|
* 21 - 50 are reserved for data type supporting tests
|
|
|
|
* 51 - are for other tests
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2015-09-02 20:33:00 +08:00
|
|
|
"use strict"
|
2015-07-20 12:42:12 +08:00
|
|
|
|
|
|
|
var oracledb = require('oracledb');
|
2015-09-02 20:33:00 +08:00
|
|
|
var should = require('should');
|
2015-07-20 12:42:12 +08:00
|
|
|
var assist = require('./dataTypeAssist.js');
|
|
|
|
var dbConfig = require('./dbConfig.js');
|
|
|
|
|
|
|
|
describe('22. dataTypeChar.js', function(){
|
2015-09-02 20:33:00 +08:00
|
|
|
|
2015-07-20 12:42:12 +08:00
|
|
|
if(dbConfig.externalAuth){
|
|
|
|
var credential = { externalAuth: true, connectString: dbConfig.connectString };
|
|
|
|
} else {
|
|
|
|
var credential = dbConfig;
|
|
|
|
}
|
|
|
|
|
2015-09-02 20:33:00 +08:00
|
|
|
var connection = null;
|
|
|
|
var tableName = "oracledb_char";
|
2015-07-20 15:56:29 +08:00
|
|
|
|
|
|
|
var strLen = [100, 1000, 2000]; // char string length
|
2015-09-02 20:33:00 +08:00
|
|
|
var strs =
|
|
|
|
[
|
|
|
|
assist.createCharString(strLen[0]),
|
|
|
|
assist.createCharString(strLen[1]),
|
|
|
|
assist.createCharString(strLen[2]),
|
|
|
|
];
|
|
|
|
|
|
|
|
before('get one connection', function(done) {
|
2015-07-20 15:56:29 +08:00
|
|
|
oracledb.getConnection(credential, function(err, conn) {
|
2015-09-02 20:33:00 +08:00
|
|
|
should.not.exist(err);
|
2015-07-20 12:42:12 +08:00
|
|
|
connection = conn;
|
2015-09-02 20:33:00 +08:00
|
|
|
done();
|
2015-07-20 12:42:12 +08:00
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2015-09-02 20:33:00 +08:00
|
|
|
after('release connection', function(done) {
|
|
|
|
connection.release( function(err) {
|
|
|
|
should.not.exist(err);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('22.1 testing CHAR data in various lengths', function() {
|
|
|
|
|
|
|
|
before('create table, insert data',function(done) {
|
|
|
|
assist.setUp(connection, tableName, strs, done);
|
|
|
|
})
|
|
|
|
|
|
|
|
after(function(done) {
|
|
|
|
connection.execute(
|
|
|
|
"DROP table " + tableName,
|
|
|
|
function(err) {
|
|
|
|
should.not.exist(err);
|
2015-07-20 15:56:29 +08:00
|
|
|
done();
|
2015-09-02 20:33:00 +08:00
|
|
|
}
|
|
|
|
);
|
|
|
|
})
|
|
|
|
|
|
|
|
it('22.1.1 works well with SELECT query', function(done) {
|
|
|
|
assist.dataTypeSupport(connection, tableName, strs, done);
|
|
|
|
})
|
|
|
|
|
|
|
|
it('22.1.2 works well with result set', function(done) {
|
|
|
|
assist.verifyResultSet(connection, tableName, strs, done);
|
|
|
|
})
|
|
|
|
|
|
|
|
it('22.1.3 works well with REF Cursor', function(done) {
|
|
|
|
assist.verifyRefCursor(connection, tableName, strs, done);
|
|
|
|
})
|
2015-07-20 15:56:29 +08:00
|
|
|
})
|
2015-09-02 20:33:00 +08:00
|
|
|
|
|
|
|
describe('22.2 stores null value correctly', function() {
|
|
|
|
it('22.2.1 testing Null, Empty string and Undefined', function(done) {
|
|
|
|
assist.verifyNullValues(connection, tableName, done);
|
|
|
|
})
|
2015-07-20 12:42:12 +08:00
|
|
|
})
|
|
|
|
})
|