Skip to content

Commit aba59f4

Browse files
committed
Optimize test cases
1 parent b0aa428 commit aba59f4

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

test/getStmtInfo.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('162. getStmtInfo.js', function() {
5050
});
5151

5252
after(async function() {
53-
await testsUtil.dropTable(tableName);
53+
await testsUtil.dropTable(conn, tableName);
5454
await conn.close();
5555
});
5656

@@ -173,7 +173,7 @@ describe('162. getStmtInfo.js', function() {
173173
}); // 162.13
174174

175175
it('162.14 CREATE and verify the data does not get created', async function() {
176-
await testsUtil.dropTable("nodb_test_162_14");
176+
await testsUtil.dropTable(conn, "nodb_test_162_14");
177177
let sql = "create table nodb_test_162_14 (a number)";
178178
const info = await conn.getStatementInfo(sql);
179179
assert.deepStrictEqual(info.bindNames, []);
@@ -186,7 +186,7 @@ describe('162. getStmtInfo.js', function() {
186186
}); // 162.14
187187

188188
it('162.15 CREATE procedure', async function() {
189-
await testsUtil.dropSource("procedure", "nodb_proc_162_15");
189+
await testsUtil.dropSource(conn, "procedure", "nodb_proc_162_15");
190190
let proc = "CREATE OR REPLACE PROCEDURE nodb_proc_162_15 (str OUT STRING) \n" +
191191
"AS \n" +
192192
"BEGIN \n" +

test/lastRowid.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ describe('228. lastRowid.js', function() {
5353
});
5454

5555
after(async () => {
56+
await testsUtil.dropTable(conn, TABLE);
5657
await conn.close();
57-
await testsUtil.dropTable(TABLE);
5858
});
5959

6060
it('228.1 examples', async () => {

test/pool.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
const oracledb = require('oracledb');
3535
const assert = require('assert');
3636
const dbConfig = require('./dbconfig.js');
37+
const testsUtil = require('./testsUtil.js');
3738

3839
describe('2. pool.js', function() {
3940

@@ -546,7 +547,7 @@ describe('2. pool.js', function() {
546547
it('2.11.1 error occurs at creating pool when poolMin (user defined) greater than or equal to poolMax (default)', async function() {
547548
const config = {
548549
user: 'notexist',
549-
password: 'nopass',
550+
password: testsUtil.generateRandomPassword(),
550551
connectString: dbConfig.connectString,
551552
poolMin: 5
552553
};
@@ -560,7 +561,7 @@ describe('2. pool.js', function() {
560561
const config = {
561562
...dbConfig,
562563
user: 'notexist',
563-
password: 'nopass',
564+
password: testsUtil.generateRandomPassword()
564565
};
565566
const pool = await oracledb.createPool(config);
566567
await assert.rejects(
@@ -878,7 +879,7 @@ describe('2. pool.js', function() {
878879
poolMax: 1,
879880
poolIncrement: 0,
880881
externalAuth: true,
881-
password: 'nopass'
882+
password: testsUtil.generateRandomPassword()
882883
};
883884
await assert.rejects(
884885
async () => await oracledb.createPool(config),

test/testsUtil.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,19 @@ testsUtil.sqlDropType = function(typeName) {
9393
`;
9494
};
9595

96-
testsUtil.createTable = async function(tableName, sql) {
97-
let plsql = testsUtil.sqlCreateTable(tableName, sql);
98-
const conn = await oracledb.getConnection(dbConfig);
96+
testsUtil.createTable = async function(conn, tableName, sql) {
97+
const plsql = testsUtil.sqlCreateTable(tableName, sql);
9998
await conn.execute(plsql);
100-
await conn.close();
10199
};
102100

103-
testsUtil.dropSource = async function(sourceType, sourceName) {
104-
let plsql = testsUtil.sqlDropSource(sourceType, sourceName);
105-
const conn = await oracledb.getConnection(dbConfig);
101+
testsUtil.dropSource = async function(conn, sourceType, sourceName) {
102+
const plsql = testsUtil.sqlDropSource(sourceType, sourceName);
106103
await conn.execute(plsql);
107-
await conn.close();
108104
};
109105

110-
testsUtil.dropTable = async function(tableName) {
111-
let plsql = testsUtil.sqlDropTable(tableName);
112-
const conn = await oracledb.getConnection(dbConfig);
106+
testsUtil.dropTable = async function(conn, tableName) {
107+
const plsql = testsUtil.sqlDropTable(tableName);
113108
await conn.execute(plsql);
114-
await conn.close();
115109
};
116110

117111
testsUtil.checkPrerequisites = async function(clientVersion = 1805000000, serverVersion = 1805000000) {

test/tpcResume.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ describe('260. tpcResume.js', function() {
7575
});
7676

7777
after(async function() {
78-
await testsUtil.dropTable("nodb_tpc_resume");
78+
const connection = await oracledb.getConnection(dbConfig);
79+
await testsUtil.dropTable(connection, "nodb_tpc_resume");
80+
await connection.close();
7981
});
8082

8183

0 commit comments

Comments
 (0)