Skip to content

Commit 9617b45

Browse files
committed
Test improvements
1 parent 8377cca commit 9617b45

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

test/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ The test suite uses [mocha](https://www.npmjs.com/package/mocha),
9393
Set the following environment variables to provide credentials for the test suite.
9494

9595
* `NODE_ORACLEDB_USER` provides the username of the schema user which you used for testing.
96-
Use the username prefix 'NJS_' when creating a new user inside the test suite. Test suite does create such users.
96+
Use the parameter *createUser* specified in `test/dbconfig.js` to create a new user within the test suite. Test suite does create such users.
9797

9898
* `NODE_ORACLEDB_PASSWORD` provides the password of the schema user which you used for testing.
9999
if you're generating a password for the user, use the predefined function testsUtil.generateRandomPassword.

test/changePassword.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('161. changePassword.js', function() {
4242
let DBA_config;
4343
let dbaConn;
4444
let sql;
45-
const myUser = dbConfig.user + "_cpw";
45+
const myUser = dbConfig.createUser();
4646
if (dbConfig.test.DBA_PRIVILEGE == true) {
4747
DBA_config = {
4848
user: dbConfig.test.DBA_user,

test/dbconfig.js

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ const config = {
5353
}
5454
};
5555

56+
let counter = 0;
57+
5658
if (process.env.NODE_ORACLEDB_CONNECTIONSTRING) {
5759
config.connectString = process.env.NODE_ORACLEDB_CONNECTIONSTRING;
5860
} else {
@@ -150,4 +152,8 @@ if (process.env.NODE_ORACLEDB_DRIVER_MODE === 'thick') {
150152
console.log("Thin mode selected");
151153
}
152154

155+
config.createUser = () => {
156+
++counter;
157+
return "NJS_" + counter.toString() + config.user;
158+
};
153159
module.exports = config;

test/jsonDualityViews1.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,13 @@ describe('272. jsonDualityView1.js', function() {
740740
describe('272.3.11 Create view without privilege ', function() {
741741
let connection = null;
742742
let conn = null;
743+
const user1 = dbConfig.createUser();
744+
const user2 = dbConfig.createUser();
743745
const pwd = testsUtil.generateRandomPassword();
744-
const createUser1 = `create user njs_test1 identified by ${pwd}`;
745-
const createUser2 = `create user njs_test2 identified by ${pwd}`;
746-
const grantPriv1 = `grant create session, resource, connect, unlimited tablespace to njs_test1`;
747-
const grantPriv2 = `grant create session to njs_test2`;
746+
const createUser1 = `create user ${user1} identified by ${pwd}`;
747+
const createUser2 = `create user ${user2} identified by ${pwd}`;
748+
const grantPriv1 = `grant create session, resource, connect, unlimited tablespace to ${user1}`;
749+
const grantPriv2 = `grant create session to ${user2}`;
748750

749751
const createTableStudent = `create table student(
750752
stuid number,
@@ -774,8 +776,8 @@ describe('272. jsonDualityView1.js', function() {
774776
if (dbConfig.test.drcp || dbConfig.test.isCmanTdm) {
775777
return;
776778
}
777-
await connection.execute(`drop user njs_test1 cascade`);
778-
await connection.execute(`drop user njs_test2 cascade`);
779+
await connection.execute(`drop user ${user1} cascade`);
780+
await connection.execute(`drop user ${user2} cascade`);
779781
await connection.close();
780782
});
781783

@@ -785,7 +787,7 @@ describe('272. jsonDualityView1.js', function() {
785787
AS
786788
student @insert @update @delete
787789
{StudentId: stuid, StudentName: name}`;
788-
conn = await oracledb.getConnection({user: 'njs_test1',
790+
conn = await oracledb.getConnection({user: user1,
789791
password: pwd,
790792
connectString: dbConfig.connectString
791793
});
@@ -807,13 +809,13 @@ describe('272. jsonDualityView1.js', function() {
807809

808810
it('272.3.11.2 Query with test2 user', async function() {
809811

810-
conn = await oracledb.getConnection({user: 'njs_test2',
812+
conn = await oracledb.getConnection({user: user2,
811813
password: pwd,
812814
connectString: dbConfig.connectString
813815
});
814816

815817
await assert.rejects(
816-
async () => await conn.execute(`select * from njs_test1.student_ov`),
818+
async () => await conn.execute(`select * from ${user1}.student_ov`),
817819
/ORA-00942:/ //ORA-00942: table or view does not exist
818820
);
819821
await conn.close();

0 commit comments

Comments
 (0)