Skip to content

Commit a69f201

Browse files
committed
Update tests
1 parent 3c7ed9d commit a69f201

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

test/binding_buffer_string.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/* Copyright (c) 2022, Oracle and/or its affiliates. */
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+
* NAME
19+
* 263.binding_buffer_string.js
20+
*
21+
* DESCRIPTION
22+
* Test case for bug 33943738
23+
*
24+
*****************************************************************************/
25+
'use strict';
26+
27+
var oracledb = require('oracledb');
28+
var assert = require('assert');
29+
const sql = require('./sqlClone.js');
30+
var dbConfig = require('./dbconfig.js');
31+
32+
describe('263. binding_buffer_string.js', function() {
33+
var connection = null;
34+
35+
var proc_blob_in_tab = "BEGIN \n" +
36+
" DECLARE \n" +
37+
" e_table_missing EXCEPTION; \n" +
38+
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
39+
" BEGIN \n" +
40+
" EXECUTE IMMEDIATE('DROP TABLE blob_tab PURGE'); \n" +
41+
" EXCEPTION \n" +
42+
" WHEN e_table_missing \n" +
43+
" THEN NULL; \n" +
44+
" END; \n" +
45+
" EXECUTE IMMEDIATE (' \n" +
46+
" CREATE TABLE blob_tab ( \n" +
47+
" id NUMBER, \n" +
48+
" blob_1 BLOB \n" +
49+
" ) \n" +
50+
" '); \n" +
51+
"END; ";
52+
var drop_table = "DROP TABLE blob_tab PURGE";
53+
before('get connection and create table', async function() {
54+
try {
55+
connection = await oracledb.getConnection(dbConfig);
56+
assert(connection);
57+
await sql.executeSql(connection, proc_blob_in_tab, {}, {});
58+
} catch (err) {
59+
assert.ifError(err);
60+
}
61+
});
62+
63+
after('release connection', async function() {
64+
try {
65+
await sql.executeSql(connection, drop_table, {}, {});
66+
await connection.release();
67+
} catch (err) {
68+
assert.ifError(err);
69+
}
70+
71+
});
72+
73+
describe('263.1 BLOB, PLSQL, BIND_IN', function() {
74+
75+
it('263.1.1 works with buffer', async function() {
76+
const data = [
77+
{a: 1, b: Buffer.from("Dummy data 1".repeat(5000), "utf-8")},
78+
{a: 2, b: Buffer.from("Dummy data 2".repeat(7500), "utf-8")}
79+
];
80+
const bindDefs = {
81+
a: { type: oracledb.NUMBER },
82+
b: { type: oracledb.DB_TYPE_BLOB }
83+
};
84+
const options = {
85+
bindDefs: bindDefs,
86+
autoCommit: true
87+
};
88+
89+
const result = await connection.executeMany("insert into blob_tab (id, blob_1) values(:a, :b)", data, options);
90+
console.log(result.rowsAffected);
91+
await connection.close();
92+
});
93+
});
94+
});

test/connHealthy.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,28 @@ describe('261. connHealthy.js', function() {
4848
assert.strictEqual(isHealthy, false);
4949
});
5050

51+
it('261.1.3 connection health on closed connection from a pool', async function() {
52+
const pool = await oracledb.createPool(
53+
{
54+
user : dbconfig.user,
55+
password : dbconfig.password,
56+
connectString : dbconfig.connectString,
57+
poolMin : 1,
58+
poolMax : 5,
59+
poolIncrement : 1,
60+
poolTimeout : 28,
61+
stmtCacheSize : 23
62+
});
63+
assert.strictEqual(pool.connectionsInUse, 0);
64+
const conn = await pool.getConnection();
65+
var isHealthy = conn.isHealthy();
66+
assert.strictEqual(isHealthy, true);
67+
await conn.close();
68+
isHealthy = conn.isHealthy();
69+
assert.strictEqual(isHealthy, false);
70+
});
71+
72+
5173
});
5274

5375
});

0 commit comments

Comments
 (0)