Skip to content

Commit d6c8825

Browse files
committed
Further test changes
1 parent a8658f0 commit d6c8825

File tree

4 files changed

+46
-62
lines changed

4 files changed

+46
-62
lines changed

test/bindTimestamp.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ describe('102. bindTimestamp.js', function() {
113113
"select * from nodb_tab_tsbind where id = :i",
114114
{ i: id },
115115
{ outFormat: oracledb.OUT_FORMAT_OBJECT });
116-
assert(result);
117116
assert.deepStrictEqual(result.rows[0].TS, bv);
118117
assert.deepStrictEqual(result.rows[0].TSTZ, bv);
119118
});
@@ -250,7 +249,6 @@ describe('102. bindTimestamp.js', function() {
250249
{ type: oracledb.DATE, dir: oracledb.BIND_OUT} ],
251250
{ autoCommit: true});
252251

253-
assert(result);
254252
assert.equal(result.outBinds[0][0], id);
255253
assert.deepStrictEqual(result.outBinds[1][0], bv);
256254

@@ -413,7 +411,6 @@ describe('102. bindTimestamp.js', function() {
413411
{ i: id },
414412
{ outFormat: oracledb.OUT_FORMAT_OBJECT });
415413

416-
assert(result);
417414
assert.deepStrictEqual(result.rows[0].TS, bv1);
418415
assert.deepStrictEqual(result.rows[0].TSTZ, bv2);
419416
});

test/binding.js

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ describe('4. binding.js', function() {
4545
let connection = null;
4646
before(async function() {
4747
connection = await oracledb.getConnection(dbConfig);
48-
assert(connection);
4948
});
5049

5150
after(async function() {
@@ -58,7 +57,6 @@ describe('4. binding.js', function() {
5857
BEGIN \
5958
p_out := 'abcdef'; \
6059
END;";
61-
assert(connection);
6260
await connection.execute(proc);
6361
let result = await connection.execute("BEGIN nodb_bindproc1(:o); END;",
6462
{
@@ -86,7 +84,6 @@ describe('4. binding.js', function() {
8684
BEGIN \
8785
p_out := 10010; \
8886
END;";
89-
assert(connection);
9087
await connection.execute(proc);
9188
let result = await connection.execute(
9289
"BEGIN nodb_bindproc2(:o); END;",
@@ -113,7 +110,6 @@ describe('4. binding.js', function() {
113110
p_inout := p_in || ' ' || p_inout; \
114111
p_out := 101; \
115112
END; ";
116-
assert(connection);
117113
await connection.execute(proc);
118114
let result = await connection.execute(
119115
"BEGIN nodb_bindproc3(:i, :io, :o); END;",
@@ -145,7 +141,6 @@ describe('4. binding.js', function() {
145141
p_inout := p_in || ' ' || p_inout; \
146142
p_out := 101; \
147143
END; ";
148-
assert(connection);
149144
await connection.execute(proc);
150145
let result = await connection.execute(
151146
"BEGIN nodb_bindproc4(:io, :o, :i); END;",
@@ -169,7 +164,6 @@ describe('4. binding.js', function() {
169164
});
170165

171166
it('4.1.5 default bind type - STRING', async function() {
172-
assert(connection);
173167
const sql = "begin :n := 1001; end;";
174168
const bindVar = { n : { dir: oracledb.BIND_OUT } };
175169
let options = { };
@@ -211,7 +205,6 @@ describe('4. binding.js', function() {
211205
});
212206

213207
afterEach(async function() {
214-
assert(connection);
215208
await connection.execute("DROP TABLE nodb_binding1 PURGE");
216209
await connection.close();
217210
});
@@ -386,7 +379,7 @@ describe('4. binding.js', function() {
386379

387380
describe('4.3 insert with DATE column and DML returning', function() {
388381
let connection = null;
389-
let createTable =
382+
const createTable =
390383
"BEGIN \
391384
DECLARE \
392385
e_table_missing EXCEPTION; \
@@ -412,7 +405,6 @@ describe('4. binding.js', function() {
412405
});
413406

414407
afterEach(async function() {
415-
assert(connection);
416408
await connection.execute("DROP TABLE nodb_binding2 PURGE");
417409
await connection.close();
418410
});
@@ -477,7 +469,6 @@ describe('4. binding.js', function() {
477469
BEGIN \
478470
p_out := 'ABCDEF GHIJK LMNOP QRSTU'; \
479471
END;";
480-
assert(connection);
481472
await connection.execute(proc);
482473
await assert.rejects(
483474
async () => {
@@ -543,7 +534,6 @@ describe('4. binding.js', function() {
543534
await connection.close();
544535
});
545536

546-
547537
it('4.5.1 DML default bind', async function() {
548538
await connection.execute(
549539
"insert into nodb_raw (num) values (:id)",
@@ -572,90 +562,87 @@ describe('4. binding.js', function() {
572562
+ "if sqlcode <> -942 then "
573563
+ "raise; "
574564
+ "end if; end;";
575-
const binds = [];
576-
let options = {};
577-
578-
const connect = await oracledb.getConnection(dbConfig);
579-
let result = await connect.execute(sql, binds, options);
565+
const connection = await oracledb.getConnection(dbConfig);
566+
const result = await connection.execute(sql);
580567
assert.deepStrictEqual(result, {});
568+
await connection.close();
581569
});
582570
});
583571

584572
// Test cases involving JSON value as input
585573
describe ('4.7 Value as JSON named/unamed test cases', function() {
574+
let connection;
575+
576+
before(async function() {
577+
connection = await oracledb.getConnection(dbConfig);
578+
});
579+
580+
after(async function() {
581+
await connection.close();
582+
});
583+
586584
it('4.7.1 valid case when numeric values are passed as it is',
587585
async function() {
588586
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
589587
const binds = [ 1, 456 ];
590-
let connect = await oracledb.getConnection(dbConfig);
591-
let result = await connect.execute(sql, binds);
588+
const result = await connection.execute(sql, binds);
592589
assert((result.rows[0][0]) instanceof Date);
593590
});
594591

595592
it('4.7.2 Valid values when one of the value is passed as JSON ',
596593
async function() {
597594
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
598595
const binds = [ 1, { val : 456 } ];
599-
600-
let connect = await oracledb.getConnection(dbConfig);
601-
let result = await connect.execute (sql, binds);
596+
const result = await connection.execute (sql, binds);
602597
assert((result.rows[0][0]) instanceof Date);
603598
});
604599

605600
it('4.7.3 Valid test case when one of the value is passed as JSON ',
606601
async function() {
607602
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
608603
const binds = [ {val : 1}, 456 ];
609-
let connect = await oracledb.getConnection(dbConfig);
610-
let result = await connect.execute(sql, binds);
604+
const result = await connection.execute(sql, binds);
611605
assert((result.rows[0][0]) instanceof Date);
612606
});
613607

614608
it ('4.7.4 Valid Test case when both values are passed as JSON',
615609
async function() {
616610
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
617611
const binds = [ {val : 1}, {val : 456 } ];
618-
619-
let connect = await oracledb.getConnection(dbConfig);
620-
const result = await connect.execute(sql, binds);
612+
const result = await connection.execute(sql, binds);
621613
assert((result.rows[0][0]) instanceof Date);
622614
});
623615

624616
it('4.7.5 Invalid Test case when value is passed as named JSON',
625617
async function() {
626618
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
627619
const binds = [ {val : 1}, { c: {val : 456 } } ];
628-
let connect = await oracledb.getConnection(dbConfig);
629620
await assert.rejects(
630-
async () => await connect.execute(sql, binds),
621+
async () => await connection.execute(sql, binds),
631622
/NJS-044:/
632623
);
633-
634624
});
635625

636626
it('4.7.6 Invalid Test case when other-value is passed as named JSON',
637627
async function() {
638628
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
639629
const binds = [ { b: {val : 1} }, {val : 456 } ];
640-
let connect = await oracledb.getConnection(dbConfig);
641630
await assert.rejects(
642-
async () => await connect.execute(sql, binds),
631+
async () => await connection.execute(sql, binds),
643632
/NJS-044:/
644633
);
645-
646634
});
647635

648636
it('4.7.7 Invalid Test case when all values is passed as named JSON',
649637
async function() {
650638
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
651639
const binds = [ { b: {val : 1} }, { c: {val : 456 } } ];
652-
let connect = await oracledb.getConnection(dbConfig);
653640
await assert.rejects(
654-
async () => await connect.execute(sql, binds),
641+
async () => await connection.execute(sql, binds),
655642
/NJS-044:/
656643
);
657-
658644
}); // 4.7.7
645+
659646
}); // 4.7
660647

661648
describe('4.8 bind DATE', function() {
@@ -763,44 +750,44 @@ describe('4. binding.js', function() {
763750
}); // 4.8
764751

765752
describe('4.9 different placeholders for bind name', function() {
753+
let connection;
754+
755+
before(async function() {
756+
connection = await oracledb.getConnection(dbConfig);
757+
});
758+
759+
after(async function() {
760+
await connection.close();
761+
});
766762

767763
it('4.9.1 test case sensitivity of quoted bind names', async function() {
768764
const sql = 'select :"test" from dual';
769765
const binds = {'"test"': 1};
770-
771-
const connect = await oracledb.getConnection(dbConfig);
772-
const result = await connect.execute(sql, binds);
766+
const result = await connection.execute(sql, binds);
773767
assert((result.rows[0][0]), 1);
774-
await connect.release();
775768
});
776769

777770
it('4.9.2 using a reserved keyword as a bind name', async function() {
778771
const sql = 'select :ROWID from dual';
779-
780-
const connect = await oracledb.getConnection(dbConfig);
781772
await assert.rejects(
782773
async () => {
783-
await connect.execute(sql, {ROWID:1});
774+
await connection.execute(sql, {ROWID:1});
784775
},
785776
//NJS-098: 1 positional bind values are required but 0 were provided
786777
/ORA-01745:|NJS-098:/
787778
);
788-
await connect.release();
789779
});
790780

791781
it('4.9.3 not using a bind name in execute statement', async function() {
792782
const sql = 'select :val from dual';
793-
794-
const connect = await oracledb.getConnection(dbConfig);
795783
await assert.rejects(
796784
async () => {
797-
await connect.execute(sql);
785+
await connection.execute(sql);
798786
},
799787
//ORA-01008: not all variables bound
800788
//NJS-098: 1 positional bind values are required but 0 were provided
801789
/ORA-01008:|NJS-098:/
802790
);
803-
await connect.release();
804791
});
805792
}); // 4.9
806793

@@ -810,16 +797,16 @@ describe('4. binding.js', function() {
810797
const sql = 'SELECT :"percent%" FROM DUAL';
811798
const binds = {percent : "percent%" };
812799

813-
const connect = await oracledb.getConnection(dbConfig);
800+
const connection = await oracledb.getConnection(dbConfig);
814801
await assert.rejects(
815802
async () => {
816-
await connect.execute(sql, binds);
803+
await connection.execute(sql, binds);
817804
},
818805
//ORA-01036: illegal variable name/number
819806
//NJS-097: no bind placeholder named: :PERCENT was found in the SQL text
820807
/ORA-01036:|NJS-097:/
821808
);
822-
await connect.release();
809+
await connection.release();
823810
});
824811
});
825812

test/constants.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,14 @@ describe('18. constants.js', function() {
4242
});
4343

4444
it('18.2 Node-oracledb Type Constants', () => {
45-
assert.strictEqual(2019, oracledb.BLOB.num);
46-
assert.strictEqual(2006, oracledb.BUFFER.num);
47-
assert.strictEqual(2017, oracledb.CLOB.num);
48-
assert.strictEqual(2021, oracledb.CURSOR.num);
49-
assert.strictEqual(2014, oracledb.DATE.num);
50-
assert.strictEqual(0, oracledb.DEFAULT);
51-
assert.strictEqual(2010, oracledb.NUMBER.num);
52-
assert.strictEqual(2001, oracledb.STRING.num);
53-
45+
assert.strictEqual(oracledb.BLOB, oracledb.DB_TYPE_BLOB);
46+
assert.strictEqual(oracledb.BUFFER, oracledb.DB_TYPE_RAW);
47+
assert.strictEqual(oracledb.CLOB, oracledb.DB_TYPE_CLOB);
48+
assert.strictEqual(oracledb.CURSOR, oracledb.DB_TYPE_CURSOR);
49+
assert.strictEqual(oracledb.DATE, oracledb.DB_TYPE_TIMESTAMP_LTZ);
50+
assert.strictEqual(oracledb.DEFAULT, 0);
51+
assert.strictEqual(oracledb.NUMBER, oracledb.DB_TYPE_NUMBER);
52+
assert.strictEqual(oracledb.STRING, oracledb.DB_TYPE_VARCHAR);
5453
});
5554

5655
it('18.3 Oracle Database Type Constants', function() {

test/fetchTypeHandler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* Testing driver fetchTypeHandler feature.
3030
*
3131
*****************************************************************************/
32+
3233
'use strict';
3334

3435
const oracledb = require('oracledb');

0 commit comments

Comments
 (0)