Skip to content

Commit 0bccb2a

Browse files
committed
Minor test improvements
1 parent 56d9ced commit 0bccb2a

File tree

2 files changed

+48
-22
lines changed

2 files changed

+48
-22
lines changed

test/jsonDualityViews5.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,27 @@ describe('276. jsonDualityView5.js', function() {
4141
let connection = null;
4242
let dbaConn = null;
4343
let isRunnable = false;
44+
let isOracleDB_23_4;
4445

4546
before(async function() {
46-
isRunnable = (!dbConfig.test.drcp);
47+
// Skip these tests for DRCP and CMAN-TDM because the user has to be
48+
// created and dropped, which leads to errors
49+
isRunnable = (!dbConfig.test.drcp && !dbConfig.test.isCmanTdm);
50+
4751
if (isRunnable) {
4852
isRunnable = await testsUtil.checkPrerequisites(2100000000, 2300000000);
4953
isRunnable = isRunnable && dbConfig.test.DBA_PRIVILEGE;
5054
}
51-
if (!isRunnable || dbConfig.test.isCmanTdm) {
55+
56+
// 23.4 requires the _id column for creating JSON Duality Views, which
57+
// is not added in these tests. So check if the Oracle Database version
58+
// is 23.4. This condition will be used for some tests to check, if the
59+
// test should be skipped.
60+
if (await testsUtil.getMajorDBVersion() === '23.4') {
61+
isOracleDB_23_4 = true;
62+
}
63+
64+
if (!isRunnable || isOracleDB_23_4) {
5265
this.skip();
5366
}
5467

@@ -103,7 +116,7 @@ describe('276. jsonDualityView5.js', function() {
103116
});
104117

105118
after(async function() {
106-
if (!isRunnable || dbConfig.test.isCmanTdm) return;
119+
if (!isRunnable || isOracleDB_23_4) return;
107120

108121
if (connection) {
109122
await testsUtil.dropTable(connection, 'student_class');

test/passwordExpiryWarning.js

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ describe('292. passwordExpiryWarning.js', function() {
7070
privilege: oracledb.SYSDBA
7171
};
7272

73+
let pool;
74+
let conns = [];
75+
7376
before(async function() {
7477
if (!dbConfig.test.DBA_PRIVILEGE || dbConfig.test.drcp) this.skip();
7578

@@ -89,6 +92,16 @@ describe('292. passwordExpiryWarning.js', function() {
8992
await connAsDBA.close();
9093
});
9194

95+
afterEach(async function() {
96+
for (const conn of conns) {
97+
await conn.close();
98+
}
99+
conns = [];
100+
if (pool) {
101+
await pool.close(0);
102+
pool = null;
103+
}
104+
});
92105

93106
it('292.1 password expiry warning', async () => {
94107
const credentials = {
@@ -99,14 +112,14 @@ describe('292. passwordExpiryWarning.js', function() {
99112

100113
const isDB23ai = await testsUtil.checkPrerequisites(undefined, 2300000000);
101114
const conn = await oracledb.getConnection(credentials);
115+
conns.push(conn);
102116
if (isDB23ai) {
103117
assert.strictEqual(conn.warning.code, 'ORA-28098');
104118
assert.strictEqual(conn.warning.errorNum, 28098);
105119
} else {
106120
assert.strictEqual(conn.warning.code, 'ORA-28002');
107121
assert.strictEqual(conn.warning.errorNum, 28002);
108122
}
109-
await conn.close();
110123
}); // 292.1
111124

112125
it('292.2 password expiry warning on a homogeneous pool', async () => {
@@ -121,16 +134,15 @@ describe('292. passwordExpiryWarning.js', function() {
121134
homogeneous: true
122135
};
123136
const isDB23ai = await testsUtil.checkPrerequisites(undefined, 2300000000);
124-
const pool = await oracledb.createPool(credentials);
137+
pool = await oracledb.createPool(credentials);
125138
const conn = await pool.getConnection();
139+
conns.push(conn);
126140
await testsUtil.sleep(1000);
127141
if (isDB23ai) {
128142
assert.strictEqual(conn.warning.message.startsWith("ORA-28098:"), true);
129143
} else {
130144
assert.strictEqual(conn.warning.message.startsWith("ORA-28002:"), true);
131145
}
132-
await conn.close();
133-
await pool.close(0);
134146
}); // 292.2
135147

136148
it('292.3 password expiry warning on a heterogeneous pool', async function() {
@@ -148,18 +160,17 @@ describe('292. passwordExpiryWarning.js', function() {
148160
homogeneous: false
149161
};
150162
const isDB23ai = await testsUtil.checkPrerequisites(undefined, 2300000000);
151-
const pool = await oracledb.createPool(credentials);
163+
pool = await oracledb.createPool(credentials);
152164
const conn = await pool.getConnection({
153165
user: userName,
154166
password: password
155167
});
168+
conns.push(conn);
156169
if (isDB23ai) {
157170
assert.strictEqual(conn.warning.message.startsWith("ORA-28098:"), true);
158171
} else {
159172
assert.strictEqual(conn.warning.message.startsWith("ORA-28002:"), true);
160173
}
161-
await conn.close();
162-
await pool.close(0);
163174
}); // 292.3
164175

165176
it('292.4 with poolMin=0 with regular user and password', async function() {
@@ -174,12 +185,10 @@ describe('292. passwordExpiryWarning.js', function() {
174185
homogeneous: true
175186
};
176187

177-
const pool = await oracledb.createPool(credentials);
188+
pool = await oracledb.createPool(credentials);
178189
const conn = await pool.getConnection();
190+
conns.push(conn);
179191
assert.strictEqual(conn.warning, undefined);
180-
181-
await conn.close();
182-
await pool.close();
183192
}); //292.4
184193

185194

@@ -196,22 +205,24 @@ describe('292. passwordExpiryWarning.js', function() {
196205
};
197206

198207
const isDB23ai = await testsUtil.checkPrerequisites(undefined, 2300000000);
199-
const pool = await oracledb.createPool(credentials);
208+
pool = await oracledb.createPool(credentials);
200209
const conn = await pool.getConnection();
210+
conns.push(conn);
201211
if (isDB23ai) {
202212
assert.strictEqual(conn.warning.code, 'ORA-28098');
203213
} else {
204214
assert.strictEqual(conn.warning.code, 'ORA-28002');
205215
}
206216

207217
await conn.close();
218+
conns = [];
208219

209220
// Check that the warning is cleared on the next connection
210221
const conn2 = await pool.getConnection();
222+
conns.push(conn2);
211223
assert.strictEqual(conn2.warning, undefined);
212224
await conn2.close();
213-
214-
await pool.close();
225+
conns = [];
215226
}); // 292.5
216227

217228
it('292.6 with poolMin=1 with password in grace time', async function() {
@@ -227,22 +238,24 @@ describe('292. passwordExpiryWarning.js', function() {
227238
};
228239

229240
const isDB23ai = await testsUtil.checkPrerequisites(undefined, 2300000000);
230-
const pool = await oracledb.createPool(credentials);
241+
pool = await oracledb.createPool(credentials);
231242
const conn = await pool.getConnection();
243+
conns.push(conn);
232244
if (isDB23ai) {
233245
assert.strictEqual(conn.warning.code, 'ORA-28098');
234246
} else {
235247
assert.strictEqual(conn.warning.code, 'ORA-28002');
236248
}
237249

238250
await conn.close();
251+
conns = [];
239252

240253
// Check that the warning is cleared on the next connection
241254
const conn2 = await pool.getConnection();
255+
conns.push(conn2);
242256
assert.strictEqual(conn2.warning, undefined);
243257
await conn2.close();
244-
245-
await pool.close();
258+
conns = [];
246259
}); // 292.6
247260

248261
it('292.7 no warning after password change on new connection', async () => {
@@ -259,6 +272,7 @@ describe('292. passwordExpiryWarning.js', function() {
259272

260273
const isDB23ai = await testsUtil.checkPrerequisites(undefined, 2300000000);
261274
const conn = await oracledb.getConnection(credentials);
275+
conns.push(conn);
262276
if (isDB23ai) {
263277
assert.strictEqual(conn.warning.code, 'ORA-28098');
264278
assert.strictEqual(conn.warning.errorNum, 28098);
@@ -268,9 +282,8 @@ describe('292. passwordExpiryWarning.js', function() {
268282
}
269283
await conn.changePassword(userName, password, newPassword);
270284
const conn1 = await oracledb.getConnection(newCredentials);
285+
conns.push(conn1);
271286
assert.strictEqual(conn1.warning, undefined);
272-
await conn.close();
273-
await conn1.close();
274287
}); // 292.7
275288

276289
});

0 commit comments

Comments
 (0)