Remove dependency on "should" from a test

This commit is contained in:
Christopher Jones 2021-05-03 15:03:25 +10:00
parent b45152e96c
commit 0a8f845b0a
2 changed files with 104 additions and 94 deletions

View File

@ -4956,7 +4956,7 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
248.1.1 test with username size 30
248.1.2 test with username size 100
248.1.3 test with username size 128
248.1.4 test with username size 129
248.1.4 test with username size 1000
248.1.5 negative test: username = null
248.1.6 negative test: username = "null"
248.1.7 negative test: username = undefined
@ -4968,7 +4968,7 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
248.2.1 test with user size 30
248.2.2 test with user size 100
248.2.3 test with user size 128
248.2.4 test with username size 129
248.2.4 test with username size 1000
248.2.5 negative test: user = null
248.2.6 negative test: username = "null"
248.2.7 negative test: username = undefined

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
* The node-oracledb test suite uses 'mocha'.
* See LICENSE.md for relevant licenses.
*
* NAME
@ -28,44 +28,45 @@
'use strict';
const oracledb = require('oracledb');
const should = require('should');
const assert = require('assert');
const dbConfig = require('./dbconfig.js');
const assist = require('./dataTypeAssist.js');
const testsUtil = require('./testsUtil.js');
describe('248. userName.js', function() {
var dbaCredential = {
const dbaCredential = {
username : dbConfig.test.DBA_user,
password : dbConfig.test.DBA_password,
connectString : dbConfig.connectString,
privilege : oracledb.SYSDBA
};
var createUser = async function(userSchema, password) {
const createUser = async function(userSchema, password) {
let dbaConn;
try {
var dbaConn = await oracledb.getConnection(dbaCredential);
dbaConn = await oracledb.getConnection(dbaCredential);
var sql = `create user ${userSchema} identified by ${password}`;
let sql = `create user ${userSchema} identified by ${password}`;
await dbaConn.execute(sql);
sql = `grant create session to ${userSchema}`;
await dbaConn.execute(sql);
await dbaConn.close();
} catch (err) {
should.not.exist(err);
assert.fail(err);
} finally {
await dbaConn.close();
}
};
var dropUser = async function(userSchema) {
const dropUser = async function(userSchema) {
try {
var dbaConn = await oracledb.getConnection(dbaCredential);
const dbaConn = await oracledb.getConnection(dbaCredential);
var sql = `drop user ${userSchema} cascade`;
const sql = `drop user ${userSchema} cascade`;
await dbaConn.execute(sql);
await dbaConn.close();
} catch (err) {
should.not.exist(err);
assert.fail(err);
}
};
@ -75,24 +76,24 @@ describe('248. userName.js', function() {
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
try {
var userSchema = await assist.createSchemaString(30);
var password = "Welcome";
const userSchema = await assist.createSchemaString(30);
const password = "Welcome";
await createUser(userSchema, password);
var credential = {
const credential = {
username : userSchema,
password : password,
connectString: dbConfig.connectString
};
var conn = await oracledb.getConnection(credential);
should.exist(conn);
const conn = await oracledb.getConnection(credential);
assert(conn);
await conn.close();
await dropUser(userSchema);
} catch (err) {
should.not.exist(err);
assert.fail(err);
}
}); // 248.1.1
@ -104,24 +105,24 @@ describe('248. userName.js', function() {
}
try {
var userSchema = await assist.createSchemaString(100);
var password = "Welcome";
const userSchema = await assist.createSchemaString(100);
const password = "Welcome";
await createUser(userSchema, password);
var credential = {
const credential = {
username : userSchema,
password : password,
connectString: dbConfig.connectString
};
var conn = await oracledb.getConnection(credential);
should.exist(conn);
let conn = await oracledb.getConnection(credential);
assert(conn);
await conn.close();
await dropUser(userSchema);
} catch (err) {
should.not.exist(err);
assert.fail(err);
}
}); // 248.1.2
@ -133,58 +134,63 @@ describe('248. userName.js', function() {
}
try {
var userSchema = await assist.createSchemaString(128);
var password = "Welcome";
const userSchema = await assist.createSchemaString(128);
const password = "Welcome";
await createUser(userSchema, password);
var credential = {
const credential = {
username : userSchema,
password : password,
connectString: dbConfig.connectString
};
var conn = await oracledb.getConnection(credential);
should.exist(conn);
const conn = await oracledb.getConnection(credential);
assert(conn);
await conn.close();
await dropUser(userSchema);
} catch (err) {
should.not.exist(err);
assert.fail(err);
}
}); // 248.1.3
it('248.1.4 test with username size 129', async function() {
it('248.1.4 test with username size 1000', async function() {
let runnable = await testsUtil.isLongUserNameRunnable();
if (!runnable) {
this.skip();
return;
}
let dbaConn;
try {
var userSchema = await assist.createSchemaString(129);
var password = "Welcome";
const userSchema = await assist.createSchemaString(1000);
const password = "Welcome";
var dbaConn = await oracledb.getConnection(dbaCredential);
dbaConn = await oracledb.getConnection(dbaCredential);
var sql = `create user ${userSchema} identified by ${password}`;
let sql = `create user ${userSchema} identified by ${password}`;
await dbaConn.execute(sql);
sql = `grant create session to ${userSchema}`;
await dbaConn.execute(sql);
await dbaConn.close();
assert.fail(); // should not be here
} catch (err) {
should.exist(err);
(err.message).should.startWith('ORA-00972:');
assert(err);
assert(err.message.startsWith('ORA-00972:'));
} finally {
await dbaConn.close();
}
}); // 248.1.4
it('248.1.5 negative test: username = null', async function() {
try {
var credential = {
const credential = {
username : null,
password : dbConfig.password,
connectString: dbConfig.connectString
@ -196,13 +202,13 @@ describe('248. userName.js', function() {
/NJS-007/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.1.5
it('248.1.6 negative test: username = "null"', async function() {
try {
var credential = {
const credential = {
username : "null",
password : dbConfig.password,
connectString: dbConfig.connectString
@ -214,13 +220,13 @@ describe('248. userName.js', function() {
/ORA-01017/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.1.6
it('248.1.7 negative test: username = undefined', async function() {
try {
var credential = {
const credential = {
username : undefined,
password : dbConfig.password,
connectString: dbConfig.connectString
@ -232,13 +238,13 @@ describe('248. userName.js', function() {
/ORA-01017/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.1.7
it('248.1.8 negative test: username = "undefined"', async function() {
try {
var credential = {
const credential = {
username : "undefined",
password : dbConfig.password,
connectString: dbConfig.connectString
@ -250,13 +256,13 @@ describe('248. userName.js', function() {
/ORA-01017/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.1.8
it('248.1.9 negative test: username = empty string', async function() {
try {
var credential = {
const credential = {
username : "",
password : dbConfig.password,
connectString: dbConfig.connectString
@ -268,13 +274,13 @@ describe('248. userName.js', function() {
/ORA-01017/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.1.9
it('248.1.10 negative test: username = NaN', async function() {
try {
var credential = {
const credential = {
username : NaN,
password : dbConfig.password,
connectString: dbConfig.connectString
@ -286,13 +292,13 @@ describe('248. userName.js', function() {
/NJS-007/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.1.10
it('248.1.11 negative test: username in array', async function() {
try {
var credential = {
const credential = {
username : ["scott", "scott"],
password : dbConfig.password,
connectString: dbConfig.connectString
@ -304,7 +310,7 @@ describe('248. userName.js', function() {
/NJS-007/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.1.11
@ -316,24 +322,24 @@ describe('248. userName.js', function() {
if (!dbConfig.test.DBA_PRIVILEGE) this.skip();
try {
var userSchema = await assist.createSchemaString(30);
var password = "Welcome";
const userSchema = await assist.createSchemaString(30);
const password = "Welcome";
await createUser(userSchema, password);
var credential = {
const credential = {
username : userSchema,
password : password,
connectString: dbConfig.connectString
};
var conn = await oracledb.getConnection(credential);
should.exist(conn);
const conn = await oracledb.getConnection(credential);
assert(conn);
await conn.close();
await dropUser(userSchema);
} catch (err) {
should.not.exist(err);
assert.fail(err);
}
}); // 248.2.1
@ -345,24 +351,24 @@ describe('248. userName.js', function() {
}
try {
var userSchema = await assist.createSchemaString(100);
var password = "Welcome";
const userSchema = await assist.createSchemaString(100);
const password = "Welcome";
await createUser(userSchema, password);
var credential = {
const credential = {
username : userSchema,
password : password,
connectString: dbConfig.connectString
};
var conn = await oracledb.getConnection(credential);
should.exist(conn);
const conn = await oracledb.getConnection(credential);
assert(conn);
await conn.close();
await dropUser(userSchema);
} catch (err) {
should.not.exist(err);
assert.fail(err);
}
}); // 248.2.2
@ -374,58 +380,62 @@ describe('248. userName.js', function() {
}
try {
var userSchema = await assist.createSchemaString(128);
var password = "Welcome";
const userSchema = await assist.createSchemaString(128);
const password = "Welcome";
await createUser(userSchema, password);
var credential = {
const credential = {
username : userSchema,
password : password,
connectString: dbConfig.connectString
};
var conn = await oracledb.getConnection(credential);
should.exist(conn);
const conn = await oracledb.getConnection(credential);
assert(conn);
await conn.close();
await dropUser(userSchema);
} catch (err) {
should.not.exist(err);
assert.fail(err);
}
}); // 248.2.3
it('248.2.4 test with username size 129', async function() {
it('248.2.4 test with username size 1000', async function() {
let runnable = await testsUtil.isLongUserNameRunnable();
if (!runnable) {
this.skip();
return;
}
let dbaConn;
try {
var userSchema = await assist.createSchemaString(129);
var password = "Welcome";
const userSchema = await assist.createSchemaString(1000);
const password = "Welcome";
var dbaConn = await oracledb.getConnection(dbaCredential);
dbaConn = await oracledb.getConnection(dbaCredential);
var sql = `create user ${userSchema} identified by ${password}`;
let sql = `create user ${userSchema} identified by ${password}`;
await dbaConn.execute(sql);
sql = `grant create session to ${userSchema}`;
await dbaConn.execute(sql);
await dbaConn.close();
assert.fail();
} catch (err) {
should.exist(err);
(err.message).should.startWith('ORA-00972:');
assert(err);
assert(err.message.startsWith('ORA-00972:')); // identifier too long
} finally {
await dbaConn.close();
}
}); // 248.2.4
it('248.2.5 negative test: username = null', async function() {
try {
var credential = {
const credential = {
user : null,
password : dbConfig.password,
connectString: dbConfig.connectString
@ -437,13 +447,13 @@ describe('248. userName.js', function() {
/NJS-007/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.2.5
it('248.2.6 negative test: username = "null"', async function() {
try {
var credential = {
const credential = {
user : "null",
password : dbConfig.password,
connectString: dbConfig.connectString
@ -455,13 +465,13 @@ describe('248. userName.js', function() {
/ORA-01017/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.2.6
it('248.2.7 negative test: username = undefined', async function() {
try {
var credential = {
const credential = {
user : undefined,
password : dbConfig.password,
connectString: dbConfig.connectString
@ -473,13 +483,13 @@ describe('248. userName.js', function() {
/ORA-01017/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.2.7
it('248.2.8 negative test: username = "undefined"', async function() {
try {
var credential = {
const credential = {
user : "undefined",
password : dbConfig.password,
connectString: dbConfig.connectString
@ -491,13 +501,13 @@ describe('248. userName.js', function() {
/ORA-01017/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.2.8
it('248.2.9 negative test: username = empty string', async function() {
try {
var credential = {
const credential = {
user : "",
password : dbConfig.password,
connectString: dbConfig.connectString
@ -509,13 +519,13 @@ describe('248. userName.js', function() {
/ORA-01017/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.2.9
it('248.2.10 negative test: username = NaN', async function() {
try {
var credential = {
const credential = {
user : NaN,
password : dbConfig.password,
connectString: dbConfig.connectString
@ -527,13 +537,13 @@ describe('248. userName.js', function() {
/NJS-007/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.2.10
it('248.2.11 negative test: username in array', async function() {
try {
var credential = {
const credential = {
user : ["scott", "scott"],
password : dbConfig.password,
connectString: dbConfig.connectString
@ -545,7 +555,7 @@ describe('248. userName.js', function() {
/NJS-007/
);
} catch (error) {
should.not.exist(error);
assert.fail(error);
}
}); // 248.2.11