|
1 |
| -/* Copyright (c) 2015, 2022, Oracle and/or its affiliates. */ |
| 1 | +/* Copyright (c) 2015, 2023, Oracle and/or its affiliates. */ |
2 | 2 |
|
3 | 3 | /******************************************************************************
|
4 | 4 | *
|
@@ -38,116 +38,106 @@ const dbConfig = require('./dbconfig.js');
|
38 | 38 |
|
39 | 39 | describe('30. dataTypeBinaryFloat.js', function() {
|
40 | 40 |
|
41 |
| - var connection = null; |
42 |
| - var tableName = "nodb_binary_float"; |
| 41 | + let connection = null; |
| 42 | + let tableName = "nodb_binary_float"; |
43 | 43 |
|
44 |
| - before('get one connection', function(done) { |
45 |
| - oracledb.getConnection(dbConfig, |
46 |
| - function(err, conn) { |
47 |
| - assert.ifError(err); |
48 |
| - connection = conn; |
49 |
| - done(); |
50 |
| - } |
51 |
| - ); |
| 44 | + before('get one connection', async function() { |
| 45 | + connection = await oracledb.getConnection(dbConfig); |
52 | 46 | });
|
53 | 47 |
|
54 |
| - after('release connection', function(done) { |
55 |
| - connection.release(function(err) { |
56 |
| - assert.ifError(err); |
57 |
| - done(); |
58 |
| - }); |
| 48 | + after('release connection', async function() { |
| 49 | + await connection.close(); |
59 | 50 | });
|
60 | 51 |
|
61 | 52 | describe('30.1 testing BINARY_FLOAT data', function() {
|
62 | 53 |
|
63 |
| - var numbers = assist.data.numbersForBinaryFloat; |
| 54 | + let numbers = assist.data.numbersForBinaryFloat; |
64 | 55 |
|
65 |
| - before('create table, insert data', function(done) { |
66 |
| - assist.setUp(connection, tableName, numbers, done); |
| 56 | + before('create table, insert data', async function() { |
| 57 | + await new Promise((resolve) => { |
| 58 | + assist.setUp(connection, tableName, numbers, resolve); |
| 59 | + }); |
67 | 60 | });
|
68 | 61 |
|
69 |
| - after(function(done) { |
| 62 | + after(async function() { |
70 | 63 | oracledb.fetchAsString = [];
|
71 |
| - connection.execute( |
72 |
| - "DROP table " + tableName + " PURGE", |
73 |
| - function(err) { |
74 |
| - assert.ifError(err); |
75 |
| - done(); |
76 |
| - } |
77 |
| - ); |
| 64 | + await connection.execute(`DROP table ` + tableName + ` PURGE`); |
78 | 65 | });
|
79 | 66 |
|
80 |
| - it('30.1.1 works well with SELECT query', function(done) { |
81 |
| - assist.dataTypeSupport(connection, tableName, numbers, done); |
| 67 | + it('30.1.1 works well with SELECT query', async function() { |
| 68 | + await new Promise((resolve) => { |
| 69 | + assist.dataTypeSupport(connection, tableName, numbers, resolve); |
| 70 | + }); |
82 | 71 | });
|
83 | 72 |
|
84 |
| - it('30.1.2 works well with result set', function(done) { |
85 |
| - assist.verifyResultSet(connection, tableName, numbers, done); |
| 73 | + it('30.1.2 works well with result set', async function() { |
| 74 | + await new Promise((resolve) => { |
| 75 | + assist.verifyResultSet(connection, tableName, numbers, resolve); |
| 76 | + }); |
86 | 77 | });
|
87 | 78 |
|
88 |
| - it('30.1.3 works well with REF Cursor', function(done) { |
89 |
| - assist.verifyRefCursor(connection, tableName, numbers, done); |
| 79 | + it('30.1.3 works well with REF Cursor', async function() { |
| 80 | + await new Promise((resolve) => { |
| 81 | + assist.verifyRefCursor(connection, tableName, numbers, resolve); |
| 82 | + }); |
90 | 83 | });
|
91 | 84 |
|
92 |
| - it('30.1.4 columns fetched from REF CURSORS can be mapped by fetchInfo settings', function(done) { |
93 |
| - assist.verifyRefCursorWithFetchInfo(connection, tableName, numbers, done); |
| 85 | + it('30.1.4 columns fetched from REF CURSORS can be mapped by fetchInfo settings', async function() { |
| 86 | + await new Promise((resolve) => { |
| 87 | + assist.verifyRefCursorWithFetchInfo(connection, tableName, numbers, resolve); |
| 88 | + }); |
94 | 89 | });
|
95 | 90 |
|
96 |
| - it('30.1.5 columns fetched from REF CURSORS can be mapped by oracledb.fetchAsString', function(done) { |
| 91 | + it('30.1.5 columns fetched from REF CURSORS can be mapped by oracledb.fetchAsString', async function() { |
97 | 92 | oracledb.fetchAsString = [ oracledb.NUMBER ];
|
98 |
| - assist.verifyRefCursorWithFetchAsString(connection, tableName, numbers, done); |
| 93 | + await new Promise((resolve) => { |
| 94 | + assist.verifyRefCursorWithFetchAsString(connection, tableName, numbers, resolve); |
| 95 | + }); |
99 | 96 | });
|
100 | 97 |
|
101 | 98 | }); // 30.1
|
102 | 99 |
|
103 | 100 | describe('30.2 stores null value correctly', function() {
|
104 |
| - it('30.2.1 testing Null, Empty string and Undefined', function(done) { |
105 |
| - assist.verifyNullValues(connection, tableName, done); |
| 101 | + it('30.2.1 testing Null, Empty string and Undefined', async function() { |
| 102 | + await new Promise((resolve) => { |
| 103 | + assist.verifyNullValues(connection, tableName, resolve); |
| 104 | + }); |
106 | 105 | });
|
107 | 106 | });
|
108 | 107 |
|
109 | 108 | describe('30.3 testing floating-point numbers which cannot be precisely represent', function() {
|
110 |
| - var nums = |
| 109 | + let nums = |
111 | 110 | [
|
112 | 111 | 2345.67,
|
113 | 112 | 9876.54321,
|
114 | 113 | 0.01234,
|
115 | 114 | 0.00000123
|
116 | 115 | ];
|
117 | 116 |
|
118 |
| - before('create table, insert data', function(done) { |
119 |
| - assist.setUp(connection, tableName, nums, done); |
| 117 | + before('create table, insert data', async function() { |
| 118 | + await new Promise((resolve) => { |
| 119 | + assist.setUp(connection, tableName, nums, resolve); |
| 120 | + }); |
120 | 121 | });
|
121 | 122 |
|
122 |
| - after(function(done) { |
123 |
| - connection.execute( |
124 |
| - "DROP table " + tableName + " PURGE", |
125 |
| - function(err) { |
126 |
| - assert.ifError(err); |
127 |
| - done(); |
128 |
| - } |
129 |
| - ); |
| 123 | + after(async function() { |
| 124 | + await connection.execute(`DROP table ` + tableName + ` PURGE`); |
130 | 125 | });
|
131 | 126 |
|
132 |
| - it('30.3.1 rounding numbers', function(done) { |
133 |
| - connection.execute( |
134 |
| - "SELECT * FROM " + tableName, |
| 127 | + it('30.3.1 rounding numbers', async function() { |
| 128 | + let result = await connection.execute( |
| 129 | + `SELECT * FROM ` + tableName, |
135 | 130 | [],
|
136 |
| - { outFormat: oracledb.OUT_FORMAT_OBJECT }, |
137 |
| - function(err, result) { |
138 |
| - assert.ifError(err); |
139 |
| - |
140 |
| - for (var i = 0; i < nums.length; i++) { |
141 |
| - result.rows[i].CONTENT.should.not.be.exactly(nums[result.rows[i].NUM]); |
142 |
| - approxeq(result.rows[i].CONTENT, nums[result.rows[i].NUM]).should.be.ok(); |
143 |
| - } |
144 |
| - done(); |
145 |
| - } |
146 |
| - ); |
| 131 | + { outFormat: oracledb.OUT_FORMAT_OBJECT }); |
| 132 | + |
| 133 | + for (let i = 0; i < nums.length; i++) { |
| 134 | + assert.notStrictEqual(result.rows[i].CONTENT, nums[result.rows[i].NUM]); |
| 135 | + assert(approxeq(result.rows[i].CONTENT, nums[result.rows[i].NUM])); |
| 136 | + } |
147 | 137 | });
|
148 | 138 |
|
149 | 139 | function approxeq(v1, v2) {
|
150 |
| - var precision = 0.001; |
| 140 | + let precision = 0.001; |
151 | 141 | return Math.abs(v1 - v2) < precision;
|
152 | 142 | }
|
153 | 143 | }); // 30.3
|
|
0 commit comments