Modify test cases to ensure they do not run in unsupported DB versions

This commit is contained in:
Sharad Chandran R 2023-10-12 20:44:17 +05:30
parent 3d5dded117
commit 4d5e3d2ea1
6 changed files with 75 additions and 19 deletions

View File

@ -267,6 +267,8 @@ describe('98.binding_DMLReturningInto.js', function() {
});
it('98.1.12 oracledb.STRING <--> DB: BLOB', async function() {
if (connection.oracleServerVersion < 1202000000)
this.skip();
index++;
const table_name = tableNamePre + index;
const content = "small string";
@ -535,6 +537,8 @@ describe('98.binding_DMLReturningInto.js', function() {
});
it('98.2.12 oracledb.STRING <--> DB: BLOB', async function() {
if (connection.oracleServerVersion < 1202000000)
this.skip();
index++;
const table_name = tableNamePre + index;
const content = null;

View File

@ -161,6 +161,8 @@ describe('224. booleanBind.js', function() {
}); // after()
it('224.1 IN bind boolean value', async function() {
if (conn.oracleServerVersion < 1202000000)
this.skip();
const binds = {
inval: true,
@ -173,6 +175,9 @@ describe('224. booleanBind.js', function() {
}); // 224.1
it('224.2 IN bind value "false"', async function() {
if (conn.oracleServerVersion < 1202000000)
this.skip();
const binds = {
inval: false,
outval: { dir: oracledb.BIND_OUT, type: oracledb.STRING, maxSize: 10 }
@ -195,21 +200,24 @@ describe('224. booleanBind.js', function() {
}); // 224.3
it('224.4 Negative - IN bind value type mismatch', async function() {
const binds = {
const binds = {
inval: { type: oracledb.DB_TYPE_BOOLEAN, val: 123 },
outval: { dir: oracledb.BIND_OUT, type: oracledb.STRING, maxSize: 10 }
};
const sql = `begin :outval := ${pkgName}.GetStringRep(:inval); end;`;
const sql = `begin :outval := ${pkgName}.GetStringRep(:inval); end;`;
await assert.rejects(
async function() {
await conn.execute(sql, binds);
},
/NJS-011/
);
); // 224.4
});
it('224.5 OUT bind value "false"', async function() {
if (conn.oracleServerVersion < 1202000000)
this.skip();
const binds = {
inval: 12,
outval: { dir: oracledb.BIND_OUT, type: oracledb.DB_TYPE_BOOLEAN }
@ -221,6 +229,9 @@ describe('224. booleanBind.js', function() {
}); // 224.5
it('224.6 OUT bind value "true"', async function() {
if (conn.oracleServerVersion < 1202000000)
this.skip();
const binds = {
inval: 9,
outval: { dir: oracledb.BIND_OUT, type: oracledb.DB_TYPE_BOOLEAN }

View File

@ -147,6 +147,9 @@ describe('32. dataTypeDate.js', function() {
describe('32.4 Select invalid dates', function() {
it('32.4.1 Negative - Invalid Year 0', async function() {
if (connection.oracleServerVersion < 1202000000)
this.skip();
const invalidYear = 0;
const sql = `SELECT DATE '${invalidYear}-01-01' FROM DUAL`;
@ -160,7 +163,33 @@ describe('32. dataTypeDate.js', function() {
);
});
it('32.4.2 Negative - Invalid Year -4713', async function() {
it('32.4.2 No ORA-01841 error in Oracle 12.1 server', async function() {
if (connection.oracleServerVersion >= 1202000000)
this.skip();
const myFetchTypeHandler = function(metadata) {
if (metadata.dbType === oracledb.DB_TYPE_DATE) {
const myConverter = (v) => {
if (v !== null) {
v = v.toLocaleString('fr');
}
return v;
};
return {converter: myConverter};
}
};
const invalidYear = 0;
const sql = `SELECT DATE '${invalidYear}-01-01' FROM DUAL`;
const binds = [];
const options = {fetchTypeHandler: myFetchTypeHandler};
const result = await connection.execute(sql, binds, options);
assert.strictEqual(typeof result.rows[0][0], 'string');
// Add an assert statement to check the result
assert.deepStrictEqual(result.rows,
[['01/01/1900, 00:00:00']]);
});
it('32.4.3 Negative - Invalid Year -4713', async function() {
const invalidYear = -4713;
const sql = `SELECT DATE '${invalidYear}-01-01' FROM DUAL`;
@ -174,7 +203,7 @@ describe('32. dataTypeDate.js', function() {
);
});
it('32.4.3 Negative - Invalid Year 10000', async function() {
it('32.4.4 Negative - Invalid Year 10000', async function() {
const invalidYear = 10000;
const sql = `SELECT DATE '${invalidYear}-01-01' FROM DUAL`;

View File

@ -150,9 +150,9 @@ describe('213. dbObject14.js', () => {
describe('213.2 Object Collection with BLOB fields', () => {
let conn;
const TABLE = 'NODB_TAB_BUF_COLLECTION_14_1';
let TABLE;
const BUF_TYPE = 'NODB_TYP_BUFFER_14_1';
const BUF_TYPE_COLLECTION = 'NODB_TYP_BUFFER_COLLECTION_14_1';
let BUF_TYPE_COLLECTION;
const TEST_PROC = 'NODB_PROC_14_1';
before(async function() {
@ -160,6 +160,14 @@ describe('213.2 Object Collection with BLOB fields', () => {
return this.skip();
}
conn = await oracledb.getConnection(dbConfig);
if (conn.oracleServerVersion < 1202000000) {
//The maximum length for 12.1 db database object names is 30 characters
TABLE = 'NODB_TAB_BUF_COLLECTION_14';
BUF_TYPE_COLLECTION = 'NODB_TYP_BUFFER_COLLECTION_14';
} else {
TABLE = 'NODB_TAB_BUF_COLLECTION_14_1';
BUF_TYPE_COLLECTION = 'NODB_TYP_BUFFER_COLLECTION_14_1';
}
let sql = `
CREATE OR REPLACE TYPE ${BUF_TYPE} AS OBJECT (

View File

@ -44,7 +44,7 @@ describe('205. dbObject6.js', () => {
before(async function() {
conn = await oracledb.getConnection(dbConfig);
if (conn.oracleServerVersion < 1200000000) {
if (conn.oracleServerVersion < 1202000000) {
this.skip();
}

View File

@ -534,6 +534,7 @@ Overview of node-oracledb functional tests
32.1.3 works well with REF Cursor
32.1.4 columns fetched from REF CURSORS can be mapped by fetchInfo settings
32.1.5 columns fetched from REF CURSORS can be mapped by oracledb.fetchAsString
32.1.6 works well with SELECT query after session TimeZone change
32.2 stores null value correctly
32.2.1 testing Null, Empty string and Undefined
32.3 insert SQL Date data
@ -541,8 +542,9 @@ Overview of node-oracledb functional tests
32.3.2 SELECT query - formatted data for comparison
32.4 Select invalid dates
32.4.1 Negative - Invalid Year 0
32.4.2 Negative - Invalid Year -4713
32.4.3 Negative - Invalid Year 10000
32.4.2 No ORA-01841 error in Oracle 12.1 server
32.4.3 Negative - Invalid Year -4713
32.4.4 Negative - Invalid Year 10000
33. dataTypeTimestamp1.js
33.1 Testing JavaScript Date with database TIMESTAMP
@ -4636,14 +4638,16 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
224. booleanBind.js
224.1 IN bind boolean value
224.2 IN bind value "false"
224.3 IN bind value "null"
224.4 Negative - IN bind value type mismatch
224.5 OUT bind value "false"
224.6 OUT bind value "true"
224.7 IN bind array with boolean data
224.8 OUT bind array with boolean data
224.9 INOUT bind record with boolean data
224.2 Negative: IN bind boolean value for 12.1 DB
224.3 IN bind value "false"
224.4 IN bind value "null"
224.5 Negative - IN bind value type mismatch
224.6 OUT bind value "false"
224.7 OUT bind value "true"
224.8 IN bind array with boolean data
224.9 OUT bind array with boolean data
224.10 INOUT bind record with boolean data
224.11 OUT bind value "null"
226. dbType01.js
226.1 DB_TYPE_VARCHAR
@ -5062,7 +5066,7 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
254.2.5 Using JSON_VALUE to extract a value from a VARCHAR2 column
254.2.6 Using dot-notation to extract a value from a VARCHAR2 column
254.3 Map javascript object into CLOB
254.3.1 Number, String type (41ms)
254.3.1 Number, String type
254.3.2 Boolean and null value
254.3.3 Array type
254.3.4 Object type