From cd7ff4edcf4cf8c767a2986dec11779f3a0bd3a5 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Thu, 23 May 2019 08:04:57 +1000 Subject: [PATCH] Add tests for Implicit Results --- test/fetchClobAsString1.js | 116 --------------------- test/fetchClobAsString2.js | 118 ---------------------- test/implicitResults.js | 195 ++++++++++++++++++++++++++++++++++++ test/list.txt | 21 ++-- test/opts/mocha.opts | 4 +- test/poolPing.js | 2 +- test/random.js | 2 +- test/resultSet1.js | 71 +------------ test/resultSet2.js | 26 ----- test/stream2.js | 59 ----------- test/testsUtil.js | 21 +++- test/writableProperties2.js | 2 +- 12 files changed, 226 insertions(+), 411 deletions(-) create mode 100644 test/implicitResults.js diff --git a/test/fetchClobAsString1.js b/test/fetchClobAsString1.js index da7bdfd4..63601898 100644 --- a/test/fetchClobAsString1.js +++ b/test/fetchClobAsString1.js @@ -1545,64 +1545,6 @@ describe('84. fetchClobAsString1.js', function() { ], done); }); // 84.3.11 - it.skip('84.3.12 works with REF CURSOR', function(done) { - var id = insertID++; - var specialStr = '84.3.12'; - var contentLength = 100; - var content = random.getRandomString(contentLength, specialStr); - - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - var ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + - "AS \n" + - "BEGIN \n" + - " OPEN clob_cursor FOR \n" + - " SELECT C from nodb_clob1 WHERE ID = " + id + "; \n" + - "END;"; - connection.execute( - ref_proc, - function(err){ - should.not.exist(err); - cb(); - } - ); - }, - function(cb) { - var sql = "BEGIN nodb_ref(:c); END;"; - var bindVar = { - c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }; - connection.execute( - sql, - bindVar, - { - outFormat : oracledb.OBJECT, - resultSet : true - }, - function(err) { - // NJS-019: ResultSet cannot be returned for non-query statements - should.exist(err); - (err.message).should.startWith("NJS-019:"); - cb(); - } - ); - }, - function(cb) { - var ref_proc_drop = "DROP PROCEDURE nodb_ref"; - connection.execute( - ref_proc_drop, - function(err){ - should.not.exist(err); - cb(); - } - ); - } - ], done); - }); // 84.3.12 - it('84.3.13 fetch CLOB with stream', function(done) { var id = insertID++; var specialStr = '84.3.13'; @@ -2553,64 +2495,6 @@ describe('84. fetchClobAsString1.js', function() { ], done); }); // 84.5.11 - it.skip('84.5.12 works with REF CURSOR', function(done) { - var id = insertID++; - var specialStr = '84.5.12'; - var contentLength = 100; - var content = random.getRandomString(contentLength, specialStr); - - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - var ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + - "AS \n" + - "BEGIN \n" + - " OPEN clob_cursor FOR \n" + - " SELECT C from nodb_clob1 WHERE ID = " + id + "; \n" + - "END;"; - connection.execute( - ref_proc, - function(err){ - should.not.exist(err); - cb(); - } - ); - }, - function(cb) { - var sql = "BEGIN nodb_ref(:c); END;"; - var bindVar = { - c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }; - connection.execute( - sql, - bindVar, - { - outFormat : oracledb.ARRAY, - resultSet : true - }, - function(err) { - // NJS-019: ResultSet cannot be returned for non-query statements - should.exist(err); - (err.message).should.startWith("NJS-019:"); - cb(); - } - ); - }, - function(cb) { - var ref_proc_drop = "DROP PROCEDURE nodb_ref"; - connection.execute( - ref_proc_drop, - function(err){ - should.not.exist(err); - cb(); - } - ); - } - ], done); - }); // 84.5.12 - it('84.5.13 fetch CLOB with stream', function(done) { var id = insertID++; var specialStr = '84.5.13'; diff --git a/test/fetchClobAsString2.js b/test/fetchClobAsString2.js index e8bf85f5..979efe7b 100644 --- a/test/fetchClobAsString2.js +++ b/test/fetchClobAsString2.js @@ -1492,65 +1492,6 @@ describe('85. fetchClobAsString2.js', function() { ], done); }); // 85.3.13 - it.skip('85.3.14 works with REF CURSOR', function(done) { - var id = insertID++; - var specialStr = '85.3.14'; - var contentLength = 100; - var content = random.getRandomString(contentLength, specialStr); - - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - var ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + - "AS \n" + - "BEGIN \n" + - " OPEN clob_cursor FOR \n" + - " SELECT C from nodb_clob1 WHERE ID = " + id + "; \n" + - "END;"; - connection.execute( - ref_proc, - function(err){ - should.not.exist(err); - cb(); - } - ); - }, - function(cb) { - var sql = "BEGIN nodb_ref(:c); END;"; - var bindVar = { - c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }; - connection.execute( - sql, - bindVar, - { - outFormat : oracledb.OBJECT, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err) { - // NJS-019: ResultSet cannot be returned for non-query statements - should.exist(err); - (err.message).should.startWith("NJS-019:"); - cb(); - } - ); - }, - function(cb) { - var ref_proc_drop = "DROP PROCEDURE nodb_ref"; - connection.execute( - ref_proc_drop, - function(err){ - should.not.exist(err); - cb(); - } - ); - } - ], done); - }); - }); // 85.3 describe('85.4 fetch CLOB columns by setting fetchInfo option and outFormat = oracledb.ARRAY', function() { @@ -2338,64 +2279,5 @@ describe('85. fetchClobAsString2.js', function() { ], done); }); // 85.5.13 - it.skip('85.5.14 works with REF CURSOR', function(done) { - var id = insertID++; - var specialStr = '85.5.14'; - var contentLength = 100; - var content = random.getRandomString(contentLength, specialStr); - - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - var ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + - "AS \n" + - "BEGIN \n" + - " OPEN clob_cursor FOR \n" + - " SELECT C from nodb_clob1 WHERE ID = " + id + "; \n" + - "END;"; - connection.execute( - ref_proc, - function(err){ - should.not.exist(err); - cb(); - } - ); - }, - function(cb) { - var sql = "BEGIN nodb_ref(:c); END;"; - var bindVar = { - c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }; - connection.execute( - sql, - bindVar, - { - outFormat : oracledb.ARRAY, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err) { - // NJS-019: ResultSet cannot be returned for non-query statements - should.exist(err); - (err.message).should.startWith("NJS-019:"); - cb(); - } - ); - }, - function(cb) { - var ref_proc_drop = "DROP PROCEDURE nodb_ref"; - connection.execute( - ref_proc_drop, - function(err){ - should.not.exist(err); - cb(); - } - ); - } - ], done); - }); - }); // 85.5 }); diff --git a/test/implicitResults.js b/test/implicitResults.js new file mode 100644 index 00000000..ea539444 --- /dev/null +++ b/test/implicitResults.js @@ -0,0 +1,195 @@ +/* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. */ + +/****************************************************************************** + * + * You may not use the identified files except in compliance with the Apache + * License, Version 2.0 (the "License.") + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + * NAME + * 192. implicitResults.js + * + * DESCRIPTION + * Test the Implicit Results feauture. + * + *****************************************************************************/ +'use strict'; + +const oracledb = require('oracledb'); +const should = require('should'); +const dbconfig = require('./dbconfig.js'); +const testsUtil = require('./testsUtil.js'); + +describe('192. implicitResults.js', () => { + + const tab1 = 'nodb_tab_impres1'; + const tab2 = 'nodb_tab_impres2'; + const queryImpres = ` + declare + c1 sys_refcursor; + c2 sys_refcursor; + begin + open c1 for + select * from ${tab1}; + + dbms_sql.return_result(c1); + + open c2 for + select * from ${tab2}; + + dbms_sql.return_result(c2); + end;`; + + before(async () => { + try { + const conn = await oracledb.getConnection(dbconfig); + + let sql = + `create table ${tab1} ( + id number(9) not null, + value varchar2(100) not null + )`; + let plsql = testsUtil.sqlCreateTable(tab1, sql); + await conn.execute(plsql); + + let sqlInsertValues = + `DECLARE \n` + + ` x NUMBER := 0; \n` + + ` n VARCHAR2(100); \n` + + `BEGIN \n` + + ` FOR i IN 1..23 LOOP \n` + + ` x := x + 1; \n` + + ` n := 'Staff ' || x; \n` + + ` INSERT INTO ${tab1} VALUES (x, n); \n` + + ` END LOOP; \n` + + `END; `; + await conn.execute(sqlInsertValues); + + sql = `create table ${tab2} ( + id number(9) not null, + tsval timestamp not null + )`; + plsql = testsUtil.sqlCreateTable(tab2, sql); + await conn.execute(plsql); + + sqlInsertValues = + `DECLARE \n` + + ` x NUMBER := 0; \n` + + ` n TIMESTAMP; \n` + + `BEGIN \n` + + ` FOR i IN 1..5 LOOP \n` + + ` x := x + 1; \n` + + ` n := systimestamp + (i / 10); \n` + + ` INSERT INTO ${tab2} VALUES (x, n); \n` + + ` END LOOP; \n` + + `END; `; + await conn.execute(sqlInsertValues); + + await conn.commit(); + await conn.close(); + } catch(err) { + should.not.exist(err); + } + }); // before() + + after(async () => { + try { + const conn = await oracledb.getConnection(dbconfig); + + let sql = `DROP TABLE ${tab1} PURGE`; + await conn.execute(sql); + + sql = `DROP TABLE ${tab2} PURGE`; + await conn.execute(sql); + + await conn.close(); + } catch(err) { + should.not.exist(err); + } + + }); // after() + + it('192.1 implicit results with rows fetched', async () => { + try { + const conn = await oracledb.getConnection(dbconfig); + const results = await conn.execute(queryImpres); + + let rows = results.implicitResults[0]; + for ( let j = 0; j < rows.length; j++) { + should.strictEqual(rows[j][1], `Staff ${j+1}`); + } + + rows = results.implicitResults[1]; + const tab2Len = 5; + should.strictEqual(rows.length, tab2Len); + + await conn.close(); + } catch(err) { + should.not.exist(err); + } + }); // 192.1 + + it('192.2 implicit Results with Result Sets', async () => { + try { + const conn = await oracledb.getConnection(dbconfig); + const results = await conn.execute(queryImpres, [], { resultSet: true }); + + // Assert the content of table 1 + let rs = await results.implicitResults[0].getRows(100); + for ( let j = 0; j < rs.length; j++) { + should.strictEqual(rs[j][1], `Staff ${j+1}`); + } + + // Assert the content of table 2 + rs = await results.implicitResults[1]; + let row, len = 0; + while ( (row = await rs.getRow()) ) { + (row[1]).should.be.a.Date(); + len++; + } + const tab2Len = 5; + should.strictEqual(len, tab2Len); + + await rs.close(); + await conn.close(); + } catch(err) { + should.not.exist(err); + } + }); // 192.2 + + it('192.3 multiple options, outFormat is OBJECT', async () => { + try { + const conn = await oracledb.getConnection(dbconfig); + let opts = { resultSet: true, outFormat: oracledb.OBJECT }; + const results = await conn.execute( queryImpres, [], opts ); + + let rs = await results.implicitResults[0].getRows(100); + for ( let j = 0; j < rs.length; j++) { + should.strictEqual(rs[j].VALUE, `Staff ${j+1}`); + } + + rs = await results.implicitResults[1]; + let row, len = 0; + while ( (row = await rs.getRow()) ) { + (row.TSVAL).should.be.a.Date(); + len++; + } + const tab2Len = 5; + should.strictEqual(len, tab2Len); + + await rs.close(); + await conn.close(); + } catch(err) { + should.not.exist(err); + } + }); // 192.3 +}); diff --git a/test/list.txt b/test/list.txt index f5ec9bfb..0689dbb2 100755 --- a/test/list.txt +++ b/test/list.txt @@ -283,11 +283,6 @@ Overview of node-oracledb functional tests 12.7 Testing maxRows 12.7.1 maxRows option is ignored when resultSet option is true 12.7.2 maxRows option is ignored with REF Cursor - 12.8 Testing errInvalidResultSet - 12.8.1 Negative: UPDATE BIND out with oracledb.CURSOR - bind by name - 12.8.2 Negative: UPDATE BIND out with oracledb.CURSOR - bind by position - 12.8.3 Negative: INSERT BIND out with oracledb.CURSOR - bind by name - 12.8.4 Negative: INSERT BIND out with oracledb.CURSOR - bind by position 13. stream1.js 13.1 Testing QueryStream @@ -324,13 +319,10 @@ Overview of node-oracledb functional tests 14.5 explicitly setting resultSet option to be false takes no effect 14.6 maxRows option is ignored as expect 14.7 Negative - queryStream() has no parameters - 14.8 Negative - give invalid SQL as first parameter - 14.9 Negatvie - give non-query SQL 14.10 metadata event - single column 14.11 metadata event - multiple columns 14.12 metadata event - all column names occurring 14.13 metadata event - no return rows - 14.14 metadata event - negative: non-query SQL 14.15 metadata event - case sensitive columns 14.16 metadata event - large number of columns 14.17 metadata event - single character column @@ -853,8 +845,6 @@ Overview of node-oracledb functional tests 55.7 getting multiple resultSets 55.7.1 can access multiple resultSet on one connection 55.7.2 can access multiple REF Cursor - 55.8 Negative - resultSet is only for query statement - 55.8.1 resultSet cannot be returned for non-query statements 55.9 test querying a PL/SQL function 55.9.1 55.10 calls getRows() once and then close RS before getting more rows @@ -1788,7 +1778,6 @@ Overview of node-oracledb functional tests 84.3.9 fetch multiple CLOB rows as String 84.3.10 fetch the same CLOB column multiple times 84.3.11 works with update statement - 84.3.12 works with REF CURSOR 84.3.13 fetch CLOB with stream 84.3.14 works with setting oracledb.maxRows < actual number of rows in the table 84.3.15 works with setting oracledb.maxRows > actual number of rows in the table @@ -1822,7 +1811,6 @@ Overview of node-oracledb functional tests 84.5.9 fetch multiple CLOB rows as String 84.5.10 fetch the same CLOB column multiple times 84.5.11 works with update statement - 84.5.12 works with REF CURSOR 84.5.13 fetch CLOB with stream 84.5.14 works with setting oracledb.maxRows < actual number of rows in the table 84.5.15 works with setting oracledb.maxRows > actual number of rows in the table @@ -1877,7 +1865,6 @@ Overview of node-oracledb functional tests 85.3.11 works with update statement 85.3.12 works with setting oracledb.maxRows < actual number of rows in the table 85.3.13 works with setting oracledb.maxRows > actual number of rows in the table - 85.3.14 works with REF CURSOR 85.4 fetch CLOB columns by setting fetchInfo option and outFormat = oracledb.ARRAY 85.4.1 works with NULL value 85.4.2 works with empty String @@ -1907,7 +1894,6 @@ Overview of node-oracledb functional tests 85.5.11 works with update statement 85.5.12 works with setting oracledb.maxRows < actual number of rows in the table 85.5.13 works with setting oracledb.maxRows > actual number of rows in the table - 85.5.14 works with REF CURSOR 86. fetchClobAsString3.js 86.1 fetch multiple CLOBs @@ -4481,4 +4467,9 @@ Overview of node-oracledb functional tests 191. currentSchema.js 191.1 the value will be empty until it has been explicitly set 191.2 SQL alternative - 191.3 Negative - can not set inexistent schema \ No newline at end of file + 191.3 Negative - can not set inexistent schema + +192. implicitResults.js + 192.1 implicit results with rows fetched + 192.2 implicit Results with Result Sets + 192.3 multiple options, outFormat is OBJECT \ No newline at end of file diff --git a/test/opts/mocha.opts b/test/opts/mocha.opts index 71904b3c..158dca52 100644 --- a/test/opts/mocha.opts +++ b/test/opts/mocha.opts @@ -216,4 +216,6 @@ test/plsqlBindList.js test/fetchRawAsString.js test/writableProperties2.js test/fetchBinaryTypesAsString.js -test/currentSchema.js \ No newline at end of file +test/currentSchema.js + +test/implicitResults.js \ No newline at end of file diff --git a/test/poolPing.js b/test/poolPing.js index fd2461d8..6d224689 100644 --- a/test/poolPing.js +++ b/test/poolPing.js @@ -140,7 +140,7 @@ describe("73. poolPing.js", function() { pool.poolPingInterval = newInterval; } catch(err) { should.exist(err); - (err.message).should.equal("Cannot assign to read only property 'poolPingInterval' of object '#'") + (err.message).should.equal("Cannot assign to read only property 'poolPingInterval' of object '#'"); } cb(); diff --git a/test/random.js b/test/random.js index 016b0aee..839bcff5 100644 --- a/test/random.js +++ b/test/random.js @@ -60,7 +60,7 @@ random.getRandomInt = function(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min)) + min; -} +}; random.getIntArray = function(N) { var arr = Array.apply(null, Array(N)); diff --git a/test/resultSet1.js b/test/resultSet1.js index 900bd1ea..660a6a16 100644 --- a/test/resultSet1.js +++ b/test/resultSet1.js @@ -1388,75 +1388,6 @@ describe('12. resultSet1.js', function() { }); } }); - }); - describe.skip('12.8 Testing errInvalidResultSet', function() { - it('12.8.1 Negative: UPDATE BIND out with oracledb.CURSOR - bind by name', function(done) { - var sql = "update nodb_rs1_emp set employees_name = 'abc' where employees_id = 1 RETURNING employees_name INTO :name"; - connection.execute( - sql, - { name: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, - { resultSet: true}, - function(err) { - should.strictEqual( - err.message, - 'NJS-019: ResultSet cannot be returned for non-query statements' - ); - done(); - } - ); - }); - - it('12.8.2 Negative: UPDATE BIND out with oracledb.CURSOR - bind by position', function(done) { - var sql = "update nodb_rs1_emp set employees_name = 'abc' where employees_id = 1 RETURNING employees_name INTO :name"; - connection.execute( - sql, - [ { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } ], - { resultSet: true}, - function(err) { - should.strictEqual( - err.message, - 'NJS-019: ResultSet cannot be returned for non-query statements' - ); - done(); - } - ); - }); - - it('12.8.3 Negative: INSERT BIND out with oracledb.CURSOR - bind by name', function(done) { - var sql = "insert into nodb_rs1_emp (:id, :name) RETURNING employees_name INTO :out"; - connection.execute( - sql, - { - id: { val:1000, type: oracledb.CURSOR, dir: oracledb.BIND_OUT }, - name: { val:'hello', type: oracledb.STRING, dir: oracledb.BIND_IN }, - out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }, - { resultSet: true}, - function(err) { - should.strictEqual( - err.message, - 'NJS-019: ResultSet cannot be returned for non-query statements' - ); - done(); - } - ); - }); - - it('12.8.4 Negative: INSERT BIND out with oracledb.CURSOR - bind by position', function(done) { - var sql = "insert into nodb_rs1_emp (:id, :name) RETURNING employees_name INTO :out"; - connection.execute( - sql, - [ 1001, 'hello', { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } ], - { resultSet: true}, - function(err) { - should.strictEqual( - err.message, - 'NJS-019: ResultSet cannot be returned for non-query statements' - ); - done(); - } - ); - }); - }); + }); // 12.7 }); diff --git a/test/resultSet2.js b/test/resultSet2.js index 895aabdc..0b248e0c 100644 --- a/test/resultSet2.js +++ b/test/resultSet2.js @@ -600,32 +600,6 @@ describe('55. resultSet2.js', function() { }); }); - describe.skip('55.8 Negative - resultSet is only for query statement', function() { - before(function(done){ - setUp(connection, tableName, done); - }); - - after(function(done) { - clearUp(connection, tableName, done); - }); - - it('55.8.1 resultSet cannot be returned for non-query statements', function(done) { - connection.should.be.ok(); - connection.execute( - "UPDATE nodb_rs2_emp SET employees_name = 'Alan' WHERE employees_id = 100", - [], - { resultSet: true }, - function(err) { - should.exist(err); - // console.log(err); - err.message.should.startWith('NJS-019:'); - done(); - } - ); - - }); - }); - describe('55.9 test querying a PL/SQL function', function() { before(function(done){ setUp(connection, tableName, done); diff --git a/test/stream2.js b/test/stream2.js index d5913848..d6edc447 100644 --- a/test/stream2.js +++ b/test/stream2.js @@ -230,41 +230,6 @@ describe('14. stream2.js', function() { done(); }); - it.skip('14.8 Negative - give invalid SQL as first parameter', function(done) { - var stream = connection.queryStream('foobar'); - - stream.on('error', function(err) { - should.exist(err); - should.strictEqual( - err.message, - "NJS-019: ResultSet cannot be returned for non-query statements" - ); - done(); - }); - - stream.on('data', function(data) { - should.not.exist(data); - }); - }); - - it.skip('14.9 Negatvie - give non-query SQL', function(done) { - var sql = "INSERT INTO nodb_stream2 VALUES (300, 'staff 300', EMPTY_CLOB())"; - var stream = connection.queryStream(sql); - - stream.on('error', function(err) { - should.exist(err); - should.strictEqual( - err.message, - "NJS-019: ResultSet cannot be returned for non-query statements" - ); - done(); - }); - - stream.on('data', function(data) { - should.not.exist(data); - }); - }); - it('14.10 metadata event - single column', function(done) { var sql = 'SELECT employee_name FROM nodb_stream2 WHERE employee_id = :id'; var stream = connection.queryStream(sql, { id: 40 }); @@ -370,30 +335,6 @@ describe('14. stream2.js', function() { stream.on('end', done); }); - it.skip('14.14 metadata event - negative: non-query SQL', function(done) { - var sql = "INSERT INTO nodb_stream2 VALUES (300, 'staff 300', EMPTY_CLOB())"; - var stream = connection.queryStream(sql); - - var metaDataRead = false; - stream.on('metadata', function() { - metaDataRead = true; - }); - - stream.on('error', function(err) { - should.exist(err); - should.strictEqual( - err.message, - "NJS-019: ResultSet cannot be returned for non-query statements" - ); - should.strictEqual(metaDataRead, false); - done(); - }); - - stream.on('data', function(data) { - should.not.exist(data); - }); - }); - it('14.15 metadata event - case sensitive columns', function(done) { async.series([ function(cb) { diff --git a/test/testsUtil.js b/test/testsUtil.js index 3ce027e9..97ef404f 100644 --- a/test/testsUtil.js +++ b/test/testsUtil.js @@ -1,4 +1,4 @@ -/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. */ +/* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. */ /****************************************************************************** * @@ -47,7 +47,7 @@ testsUtil.assertThrowsAsync = async function(fn, RegExp) { } }; -testsUtil.createTable = async function(tableName, sql) { +testsUtil.sqlCreateTable = function(tableName, sql) { let sqlCreateTab = `BEGIN \n` + ` DECLARE \n` + @@ -61,10 +61,25 @@ testsUtil.createTable = async function(tableName, sql) { ` END; \n` + ` EXECUTE IMMEDIATE (' ${sql} '); \n` + `END; `; + return sqlCreateTab; +}; +testsUtil.createTable = async function(tableName, sql) { + let plsql = testsUtil.sqlCreateTable(tableName, sql); try { const conn = await oracledb.getConnection(dbconfig); - await conn.execute(sqlCreateTab); + await conn.execute(plsql); + await conn.close(); + } catch(err) { + console.log('Error in creating table:\n', err); + } +}; + +testsUtil.dropTable = async function(tableName) { + let sql = `DROP TABLE ${tableName} PURGE`; + try { + const conn = await oracledb.getConnection(dbconfig); + await conn.execute(sql); await conn.close(); } catch(err) { console.log('Error in creating table:\n', err); diff --git a/test/writableProperties2.js b/test/writableProperties2.js index 2ed137a3..f0e5becf 100644 --- a/test/writableProperties2.js +++ b/test/writableProperties2.js @@ -76,7 +76,7 @@ describe('189. writableProperties2.js', function() { should.not.exist(err); } } - }) + }); it('189.1 Allows overwriting of public methods on SodaDatabase instance', async function() { try {