Skip to content

Commit 7d7ca35

Browse files
committed
Allow instanceof.js and writableProperties.js to be run when located outside the git clone
1 parent 26bf62f commit 7d7ca35

File tree

3 files changed

+18
-106
lines changed

3 files changed

+18
-106
lines changed

test/instanceof.js

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -35,62 +35,15 @@ var oracledb = require('oracledb');
3535
var should = require('should');
3636
var dbConfig = require('./dbconfig.js');
3737

38-
try {
39-
oracledbCLib = require('../build/Release/oracledb');
40-
} catch (err) {
41-
if (err.code === 'MODULE_NOT_FOUND') {
42-
oracledbCLib = require('../build/Debug/oracledb');
43-
} else {
44-
throw err;
45-
}
46-
}
47-
4838
describe('45. instanceof.js', function() {
4939

50-
it('45.1 all constructors have been accounted for', function(done) {
51-
var cLibKeysIdx;
52-
var cLibKeys;
53-
var instKeysIdx;
54-
var instKeys;
55-
var foundAllConstructors = true;
56-
57-
cLibKeys = Object.keys(oracledbCLib);
58-
instKeys = Object.keys(oracledb);
59-
60-
cLibLoop:
61-
for (cLibKeysIdx = 0; cLibKeysIdx < cLibKeys.length; cLibKeysIdx += 1) {
62-
if (typeof oracledbCLib[cLibKeys[cLibKeysIdx]] !== 'function') {
63-
continue cLibLoop;
64-
}
65-
66-
for (instKeysIdx = 0; instKeysIdx < instKeys.length; instKeysIdx += 1) {
67-
if (cLibKeys[cLibKeysIdx] === instKeys[instKeysIdx] ||
68-
// The following exception is because the Lob class is documented as "Lob"
69-
// so that's how it was exposed on the instance
70-
cLibKeys[cLibKeysIdx] === 'ILob' && instKeys[instKeysIdx] === 'Lob'
71-
) {
72-
continue cLibLoop;
73-
}
74-
}
75-
76-
foundAllConstructors = false;
77-
console.log('Failed to account for ' + cLibKeys[cLibKeysIdx]);
78-
79-
break cLibLoop;
80-
}
81-
82-
foundAllConstructors.should.be.true;
83-
84-
done();
85-
});
86-
87-
it('45.2 instanceof works for the oracledb instance', function(done) {
40+
it('45.1 instanceof works for the oracledb instance', function(done) {
8841
(oracledb instanceof oracledb.Oracledb).should.be.true;
8942

9043
done();
9144
});
9245

93-
it('45.3 instanceof works for pool instances', function(done) {
46+
it('45.2 instanceof works for pool instances', function(done) {
9447
oracledb.createPool(
9548
{
9649
externalAuth : dbConfig.externalAuth,
@@ -115,7 +68,7 @@ describe('45. instanceof.js', function() {
11568
);
11669
});
11770

118-
it('45.4 instanceof works for connection instances', function(done) {
71+
it('45.3 instanceof works for connection instances', function(done) {
11972
oracledb.getConnection(dbConfig, function(err, conn) {
12073
should.not.exist(err);
12174

@@ -129,7 +82,7 @@ describe('45. instanceof.js', function() {
12982
});
13083
});
13184

132-
it('45.5 instanceof works for resultset instances', function(done) {
85+
it('45.4 instanceof works for resultset instances', function(done) {
13386
oracledb.getConnection(dbConfig, function(err, conn) {
13487
should.not.exist(err);
13588

@@ -158,7 +111,7 @@ describe('45. instanceof.js', function() {
158111
});
159112
});
160113

161-
it('45.6 instanceof works for lob instances', function(done) {
114+
it('45.5 instanceof works for lob instances', function(done) {
162115
oracledb.getConnection(dbConfig, function(err, conn) {
163116
should.not.exist(err);
164117

test/list.txt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,11 @@ Overview of node-oracledb functional tests
528528
- 44.8 maxSize option applies to each elements of an array
529529

530530
45. instanceof.js
531-
45.1 all constructors have been accounted for
532-
45.2 instanceof works for the oracledb instance
533-
45.3 instanceof works for pool instances
534-
45.4 instanceof works for connection instances
535-
45.5 instanceof works for resultset instances
536-
45.6 instanceof works for lob instances
531+
45.1 instanceof works for the oracledb instance
532+
45.2 instanceof works for pool instances
533+
45.3 instanceof works for connection instances
534+
45.4 instanceof works for resultset instances
535+
45.5 instanceof works for lob instances
537536

538537
51. accessTerminatedPoolAttributes.js
539538
can not access attributes of terminated pool
@@ -667,8 +666,7 @@ Overview of node-oracledb functional tests
667666
65.1 an uninitialized Lob is returned from a PL/SQL block
668667

669668
66. writableProperties.js
670-
66.1 allows overwriting of public methods on the oracledb instance
671-
66.2 allows overwriting of public methods on pool instances
672-
66.3 allows overwriting of public methods on connection instances
673-
66.4 allows overwriting of public methods on resultset instances
674-
66.5 allows overwriting of public methods on lob instances
669+
66.1 allows overwriting of public methods on pool instances
670+
66.2 allows overwriting of public methods on connection instances
671+
66.3 allows overwriting of public methods on resultset instances
672+
66.4 allows overwriting of public methods on lob instances

test/writableProperties.js

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,48 +23,9 @@ var oracledb = require('oracledb');
2323
var should = require('should');
2424
var dbConfig = require('./dbconfig.js');
2525

26-
try {
27-
oracledbCLib = require('../build/Release/oracledb');
28-
} catch (err) {
29-
if (err.code === 'MODULE_NOT_FOUND') {
30-
oracledbCLib = require('../build/Debug/oracledb');
31-
} else {
32-
throw err;
33-
}
34-
}
35-
3626
describe('66. writeableProperties.js', function() {
37-
it('66.1 allows overwriting of public methods on the oracledb instance', function(done) {
38-
var keys = Object.keys(oracledb);
39-
var keysIdx;
40-
var originalFunction;
41-
42-
function isConstructorFunction(name) {
43-
// The following has an exception for ILob, which was documented and
44-
// exposed on oracledb as Lob
45-
return typeof oracledbCLib[name] === 'function' || name === 'Lob';
46-
}
47-
48-
for (keysIdx = 0; keysIdx < keys.length; keysIdx += 1) {
49-
if (typeof oracledb[keys[keysIdx]] === 'function' &&
50-
!isConstructorFunction(keys[keysIdx]) // skip constructor functions from the C layer
51-
) {
52-
try {
53-
originalFunction = oracledb[keys[keysIdx]];
54-
55-
oracledb[keys[keysIdx]] = function() {};
56-
57-
oracledb[keys[keysIdx]] = originalFunction;
58-
} catch (err) {
59-
should.not.exist(err);
60-
}
61-
}
62-
}
63-
64-
done();
65-
});
6627

67-
it('66.2 allows overwriting of public methods on pool instances', function(done) {
28+
it('66.1 allows overwriting of public methods on pool instances', function(done) {
6829
oracledb.createPool(
6930
{
7031
externalAuth : dbConfig.externalAuth,
@@ -107,7 +68,7 @@ describe('66. writeableProperties.js', function() {
10768
);
10869
});
10970

110-
it('66.3 allows overwriting of public methods on connection instances', function(done) {
71+
it('66.2 allows overwriting of public methods on connection instances', function(done) {
11172
oracledb.getConnection(dbConfig, function(err, conn) {
11273
var keys;
11374
var keysIdx;
@@ -139,7 +100,7 @@ describe('66. writeableProperties.js', function() {
139100
});
140101
});
141102

142-
it('66.4 allows overwriting of public methods on resultset instances', function(done) {
103+
it('66.3 allows overwriting of public methods on resultset instances', function(done) {
143104
oracledb.getConnection(dbConfig, function(err, conn) {
144105
should.not.exist(err);
145106

@@ -186,7 +147,7 @@ describe('66. writeableProperties.js', function() {
186147
});
187148
});
188149

189-
it('66.5 allows overwriting of public methods on lob instances', function(done) {
150+
it('66.4 allows overwriting of public methods on lob instances', function(done) {
190151
oracledb.getConnection(dbConfig, function(err, conn) {
191152
should.not.exist(err);
192153

0 commit comments

Comments
 (0)