Skip to content

Commit ed985c8

Browse files
committed
Add regression tests
1 parent 5447f06 commit ed985c8

File tree

5 files changed

+141
-15
lines changed

5 files changed

+141
-15
lines changed

test/v8Getter.js renamed to test/jsObjectGetter1.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
* See LICENSE.md for relevant licenses.
2020
*
2121
* NAME
22-
* 140. v8Getter.js
22+
* 140. jsObjectGetter1.js
2323
*
2424
* DESCRIPTION
25-
* Test v8 object getter functions. These cases overwrite the getter()
26-
* functions.
25+
* These tests overwrite the getter methods of node-oracledb javaScript
26+
* objects.
2727
*
2828
*****************************************************************************/
2929
'use strict';
@@ -33,7 +33,7 @@ var should = require('should');
3333
var async = require('async');
3434
var dbConfig = require('./dbconfig.js');
3535

36-
describe('140. v8Getter.js', function() {
36+
describe('140. jsObjectGetter1.js', function() {
3737

3838
var connection = null;
3939
var tableName = "nodb_tab_v8getter";

test/jsObjectGetter2.js

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. */
2+
3+
/******************************************************************************
4+
*
5+
* You may not use the identified files except in compliance with the Apache
6+
* License, Version 2.0 (the "License.")
7+
*
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
*
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
19+
* See LICENSE.md for relevant licenses.
20+
*
21+
* NAME
22+
* 171. jsObjectGetter2.js
23+
*
24+
* DESCRIPTION
25+
* It checks the safe use of the Maybe value returned by
26+
* JS Object Set methods.
27+
*
28+
*****************************************************************************/
29+
'use strict';
30+
31+
const oracledb = require('oracledb');
32+
const should = require('should');
33+
const dbconfig = require('./dbconfig.js');
34+
35+
describe('171. jsObjectGetter2.js', () => {
36+
37+
it.skip('171.1 oracledb.fetchAsBuffer', () => {
38+
let foo = [ oracledb.BLOB ];
39+
Object.defineProperty(foo, '0', {
40+
get: function() {
41+
throw 'Nope';
42+
}
43+
});
44+
45+
try {
46+
oracledb.fetchAsBuffer = foo;
47+
} catch(err) {
48+
console.log(err);
49+
} finally {
50+
oracledb.fetchAsBuffer = []; // restore
51+
}
52+
}); // 171.1
53+
54+
it.skip('171.2 oracledb.fetchAsString', () => {
55+
let foo = [ oracledb.CLOB ];
56+
Object.defineProperty(foo, '0', {
57+
get: function() {
58+
throw 'Nope';
59+
}
60+
});
61+
62+
try {
63+
oracledb.fetchAsString = foo;
64+
} catch(err) {
65+
console.log(err);
66+
} finally {
67+
oracledb.fetchAsString = []; // restore
68+
}
69+
}); // 171.2
70+
71+
it.skip('171.3 data bind', async () => {
72+
let conn;
73+
try {
74+
conn = await oracledb.getConnection(dbconfig);
75+
76+
let tableName = "nodb_tab_171_3";
77+
let proc = "BEGIN \n" +
78+
" DECLARE \n" +
79+
" e_table_missing EXCEPTION; \n" +
80+
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
81+
" BEGIN \n" +
82+
" EXECUTE IMMEDIATE('DROP TABLE " + tableName + " PURGE'); \n" +
83+
" EXCEPTION \n" +
84+
" WHEN e_table_missing \n" +
85+
" THEN NULL; \n" +
86+
" END; \n" +
87+
" EXECUTE IMMEDIATE (' \n" +
88+
" CREATE TABLE " + tableName + " ( \n" +
89+
" id NUMBER, \n" +
90+
" name VARCHAR2(20) \n" +
91+
" ) \n" +
92+
" '); \n" +
93+
"END; ";
94+
await conn.execute(proc);
95+
96+
let sqlInsert = "INSERT INTO " + tableName + " VALUES (:id, :nm)";
97+
let bindVar = [2, 'Alison'];
98+
Object.defineProperty(bindVar, '0', {
99+
get: function() {
100+
throw 'Nope';
101+
}
102+
});
103+
await conn.execute(sqlInsert, bindVar);
104+
105+
let sqlDrop = "DROP TABLE " + tableName + " PURGE";
106+
await conn.execute(sqlDrop);
107+
108+
} catch(err) {
109+
should.not.exist(err);
110+
} finally {
111+
if (conn) {
112+
try {
113+
await conn.close();
114+
} catch(err) {
115+
should.not.exist(err);
116+
}
117+
}
118+
}
119+
}); // 171.3
120+
});

test/list.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,7 +3631,7 @@ Overview of node-oracledb functional tests
36313631
139.1 columns fetched from REF CURSORS can be mapped by fetchInfo settings
36323632
139.2 fetchAsString takes effect as well
36333633

3634-
140. v8Getter.js
3634+
140. jsObjectGetter1.js
36353635
140.1 Negative: overwrite the getter() function of bind in objects
36363636
140.1.1 ProcessBindsByName()
36373637
140.1.2 ProcessBindsByPos()
@@ -4224,8 +4224,13 @@ Overview of node-oracledb functional tests
42244224
170.8 works with poolAlias
42254225
170.9 works with and without poolAlias
42264226
170.10 Negative - try to modify read-only property pool.status
4227-
171.11 drainTime = 0
4228-
171.12 drainTime = -3
4229-
171.13 drainTime = NaN
4230-
171.14 draining a pool will not block the other pool
4231-
171.15 draining a pool will not block another aliased pool
4227+
170.11 drainTime = 0
4228+
170.12 drainTime = -3
4229+
170.13 drainTime = NaN
4230+
170.14 draining a pool will not block the other pool
4231+
170.15 draining a pool will not block another aliased pool
4232+
4233+
171. jsObjectGetter2.js
4234+
171.1 oracledb.fetchAsBuffer
4235+
171.2 oracledb.fetchAsString
4236+
171.3 data bind

test/opts/mocha.opts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,4 @@ test/soda3.js
196196
test/sodaCallback.js
197197

198198
test/soda4.js
199+
test/jsObjectGetter2.js

test/poolDrain.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ describe('170. poolDrain.js', () => {
198198
}
199199
}); // 170.10
200200

201-
it('171.11 drainTime = 0', async () => {
201+
it('170.11 drainTime = 0', async () => {
202202
try {
203203
let pool = await oracledb.createPool(settings);
204204

@@ -214,7 +214,7 @@ describe('170. poolDrain.js', () => {
214214
}
215215
});
216216

217-
it('171.12 drainTime = -3', async () => {
217+
it('170.12 drainTime = -3', async () => {
218218
try {
219219
let pool = await oracledb.createPool(settings);
220220

@@ -231,7 +231,7 @@ describe('170. poolDrain.js', () => {
231231
}
232232
});
233233

234-
it('171.13 drainTime = NaN', async () => {
234+
it('170.13 drainTime = NaN', async () => {
235235
try {
236236
let pool = await oracledb.createPool(settings);
237237

@@ -248,7 +248,7 @@ describe('170. poolDrain.js', () => {
248248
}
249249
});
250250

251-
it('171.14 draining a pool will not block the other pool', async () => {
251+
it('170.14 draining a pool will not block the other pool', async () => {
252252
try {
253253
let pool_1 = await oracledb.createPool(settings);
254254
let pool_2 = await oracledb.createPool(settings);
@@ -271,7 +271,7 @@ describe('170. poolDrain.js', () => {
271271
}
272272
});
273273

274-
it('171.15 draining a pool will not block another aliased pool', async () => {
274+
it('170.15 draining a pool will not block another aliased pool', async () => {
275275
try {
276276
let pool_1 = await oracledb.createPool(settings);
277277
let cred = {

0 commit comments

Comments
 (0)