-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathresultSetClose.js
140 lines (111 loc) · 3.89 KB
/
resultSetClose.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
/******************************************************************************
*
* This software is dual-licensed to you under the Universal Permissive License
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
* either license.
*
* If you elect to accept the software under the Apache License, Version 2.0,
* the following applies:
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://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
* 53. resultSetClose.js
*
* DESCRIPTION
* Negative cases against resulstSet.
*
*****************************************************************************/
'use strict';
const oracledb = require('oracledb');
const assert = require('assert');
const dbConfig = require('./dbconfig.js');
const assist = require('./dataTypeAssist.js');
describe('53. resultSetClose.js', function() {
let connection = null;
let resultSet = null;
const tableName = "nodb_number";
const numbers = assist.data.numbers;
before(async function() {
connection = await oracledb.getConnection(dbConfig);
await assist.setUp(connection, tableName, numbers);
const result = await connection.execute(
`SELECT * FROM ` + tableName + ` ORDER BY num`,
[],
{ resultSet: true, outFormat: oracledb.OUT_FORMAT_OBJECT });
resultSet = result.resultSet;
assert(resultSet.metaData);
const t = resultSet.metaData;
assert.strictEqual(t[0].name, 'NUM');
assert.strictEqual(t[1].name, 'CONTENT');
await resultSet.close();
}); // before
after(async function() {
await connection.execute(`DROP TABLE ` + tableName + ` PURGE`);
await connection.close();
}); // after
it('53.1 can not get metaData property', function() {
assert.strictEqual(resultSet.metaData, undefined);
}); // 53.1
it('53.2 can not call close() again', async function() {
await assert.rejects(
async () => {
await resultSet.close();
},
/NJS-018:/ //'NJS-018: invalid ResultSet'
);
}); // 53.2
it('53.3 can not call getRow()', async function() {
await assert.rejects(
async () => {
await resultSet.getRow();
},
/NJS-018:/ //'NJS-018: invalid ResultSet'
);
}); // 53.3
it('53.4 can not call getRows()', async function() {
const numRows = 3;
await assert.rejects(
async () => {
await resultSet.getRows(numRows);
},
/NJS-018:/ //'NJS-018: invalid ResultSet'
);
}); // 53.4
it('53.5 can not call toQueryStream()', async function() {
await assert.rejects(
async () => {
await resultSet.toQueryStream();
},
/NJS-041:/ //NJS-041: cannot convert ResultSet to QueryStream after invoking methods/
);
}); // 53.5
it('53.6 can call getRow() again in the callback of getRow()', async function() {
let rs2 = null;
const tab = "nodb_float";
await assist.setUp(connection, tab, numbers);
const result = await connection.execute(
`SELECT * FROM ` + tab + ` ORDER BY num`,
[],
{ resultSet: true, outFormat: oracledb.OUT_FORMAT_OBJECT });
rs2 = result.resultSet;
const row = await rs2.getRow();
assert(row);
const row2 = await rs2.getRow();
assert(row2);
await rs2.close();
await connection.execute(`DROP TABLE ` + tab + ` PURGE`);
}); // 53.6
});