diff --git a/test/getStmtInfo.js b/test/getStmtInfo.js index b97d13df..8ea08918 100644 --- a/test/getStmtInfo.js +++ b/test/getStmtInfo.js @@ -50,7 +50,7 @@ describe('162. getStmtInfo.js', function() { }); after(async function() { - await testsUtil.dropTable(tableName); + await testsUtil.dropTable(conn, tableName); await conn.close(); }); @@ -173,7 +173,7 @@ describe('162. getStmtInfo.js', function() { }); // 162.13 it('162.14 CREATE and verify the data does not get created', async function() { - await testsUtil.dropTable("nodb_test_162_14"); + await testsUtil.dropTable(conn, "nodb_test_162_14"); let sql = "create table nodb_test_162_14 (a number)"; const info = await conn.getStatementInfo(sql); assert.deepStrictEqual(info.bindNames, []); @@ -186,7 +186,7 @@ describe('162. getStmtInfo.js', function() { }); // 162.14 it('162.15 CREATE procedure', async function() { - await testsUtil.dropSource("procedure", "nodb_proc_162_15"); + await testsUtil.dropSource(conn, "procedure", "nodb_proc_162_15"); let proc = "CREATE OR REPLACE PROCEDURE nodb_proc_162_15 (str OUT STRING) \n" + "AS \n" + "BEGIN \n" + diff --git a/test/lastRowid.js b/test/lastRowid.js index 9736e969..3c7a423b 100644 --- a/test/lastRowid.js +++ b/test/lastRowid.js @@ -53,8 +53,8 @@ describe('228. lastRowid.js', function() { }); after(async () => { + await testsUtil.dropTable(conn, TABLE); await conn.close(); - await testsUtil.dropTable(TABLE); }); it('228.1 examples', async () => { diff --git a/test/pool.js b/test/pool.js index e7f5ca77..7dd6fe3d 100644 --- a/test/pool.js +++ b/test/pool.js @@ -34,6 +34,7 @@ const oracledb = require('oracledb'); const assert = require('assert'); const dbConfig = require('./dbconfig.js'); +const testsUtil = require('./testsUtil.js'); describe('2. pool.js', function() { @@ -546,7 +547,7 @@ describe('2. pool.js', function() { it('2.11.1 error occurs at creating pool when poolMin (user defined) greater than or equal to poolMax (default)', async function() { const config = { user: 'notexist', - password: 'nopass', + password: testsUtil.generateRandomPassword(), connectString: dbConfig.connectString, poolMin: 5 }; @@ -560,7 +561,7 @@ describe('2. pool.js', function() { const config = { ...dbConfig, user: 'notexist', - password: 'nopass', + password: testsUtil.generateRandomPassword() }; const pool = await oracledb.createPool(config); await assert.rejects( @@ -878,7 +879,7 @@ describe('2. pool.js', function() { poolMax: 1, poolIncrement: 0, externalAuth: true, - password: 'nopass' + password: testsUtil.generateRandomPassword() }; await assert.rejects( async () => await oracledb.createPool(config), diff --git a/test/testsUtil.js b/test/testsUtil.js index 938b93e9..97fbbbc2 100644 --- a/test/testsUtil.js +++ b/test/testsUtil.js @@ -93,25 +93,19 @@ testsUtil.sqlDropType = function(typeName) { `; }; -testsUtil.createTable = async function(tableName, sql) { - let plsql = testsUtil.sqlCreateTable(tableName, sql); - const conn = await oracledb.getConnection(dbConfig); +testsUtil.createTable = async function(conn, tableName, sql) { + const plsql = testsUtil.sqlCreateTable(tableName, sql); await conn.execute(plsql); - await conn.close(); }; -testsUtil.dropSource = async function(sourceType, sourceName) { - let plsql = testsUtil.sqlDropSource(sourceType, sourceName); - const conn = await oracledb.getConnection(dbConfig); +testsUtil.dropSource = async function(conn, sourceType, sourceName) { + const plsql = testsUtil.sqlDropSource(sourceType, sourceName); await conn.execute(plsql); - await conn.close(); }; -testsUtil.dropTable = async function(tableName) { - let plsql = testsUtil.sqlDropTable(tableName); - const conn = await oracledb.getConnection(dbConfig); +testsUtil.dropTable = async function(conn, tableName) { + const plsql = testsUtil.sqlDropTable(tableName); await conn.execute(plsql); - await conn.close(); }; testsUtil.checkPrerequisites = async function(clientVersion = 1805000000, serverVersion = 1805000000) { diff --git a/test/tpcResume.js b/test/tpcResume.js index d82b0db6..6c340069 100644 --- a/test/tpcResume.js +++ b/test/tpcResume.js @@ -75,7 +75,9 @@ describe('260. tpcResume.js', function() { }); after(async function() { - await testsUtil.dropTable("nodb_tpc_resume"); + const connection = await oracledb.getConnection(dbConfig); + await testsUtil.dropTable(connection, "nodb_tpc_resume"); + await connection.close(); });