Skip to content

Commit 6d19f01

Browse files
committed
Enhance the edition test
1 parent 598aa7c commit 6d19f01

File tree

1 file changed

+48
-32
lines changed

1 file changed

+48
-32
lines changed

test/editionTest.js

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ describe('160. editionTest.js', function() {
4444
if (!dbConfig.test.DBA_PRIVILEGE) {
4545
isRunnable = false;
4646
callback(null);
47+
return;
4748
}
4849

4950
oracledb.getConnection(dbConfig, function(err, connection) {
50-
if (err) callback(err);
51-
51+
if (err) {
52+
callback(err);
53+
return;
54+
}
5255
if (connection.oracleServerVersion < 1202000100) {
5356
isRunnable = false;
5457
} else {
@@ -87,33 +90,21 @@ describe('160. editionTest.js', function() {
8790
);
8891
},
8992
function(cb) {
90-
var sql = "DROP EDITION nodb_edition_two CASCADE";
91-
dbaConn.execute(
92-
sql,
93-
function(err) {
94-
if (err) {
95-
(err.message).should.startWith('ORA-38802:');
96-
// ORA-38802: edition does not exist
97-
}
98-
cb();
99-
}
100-
);
101-
},
102-
function(cb) {
103-
var sql = "DROP EDITION nodb_edition_one CASCADE";
104-
dbaConn.execute(
105-
sql,
106-
function(err) {
107-
if (err) {
108-
(err.message).should.startWith('ORA-38802:');
109-
}
110-
cb();
111-
}
112-
);
113-
},
114-
// Create edition nodb_edition_one
115-
function(cb) {
116-
var sql = "CREATE EDITION nodb_edition_one";
93+
//var sql = "DROP EDITION nodb_edition_one CASCADE";
94+
let sql = "BEGIN \n" +
95+
" DECLARE \n" +
96+
" e_edition_missing EXCEPTION; \n" +
97+
" PRAGMA EXCEPTION_INIT(e_edition_missing, -38802); \n" +
98+
" BEGIN \n" +
99+
" EXECUTE IMMEDIATE('DROP EDITION nodb_edition_one CASCADE'); \n" +
100+
" EXCEPTION \n" +
101+
" WHEN e_edition_missing \n" +
102+
" THEN NULL; \n" +
103+
" END; \n" +
104+
" EXECUTE IMMEDIATE (' \n" +
105+
" CREATE EDITION nodb_edition_one\n" +
106+
" '); \n" +
107+
"END; ";
117108
dbaConn.execute(
118109
sql,
119110
function(err) {
@@ -122,9 +113,21 @@ describe('160. editionTest.js', function() {
122113
}
123114
);
124115
},
125-
// Create edition nodb_edition_two
126116
function(cb) {
127-
var sql = "CREATE EDITION nodb_edition_two";
117+
let sql = "BEGIN \n" +
118+
" DECLARE \n" +
119+
" e_edition_missing EXCEPTION; \n" +
120+
" PRAGMA EXCEPTION_INIT(e_edition_missing, -38802); \n" +
121+
" BEGIN \n" +
122+
" EXECUTE IMMEDIATE('DROP EDITION nodb_edition_two CASCADE'); \n" +
123+
" EXCEPTION \n" +
124+
" WHEN e_edition_missing \n" +
125+
" THEN NULL; \n" +
126+
" END; \n" +
127+
" EXECUTE IMMEDIATE (' \n" +
128+
" CREATE EDITION nodb_edition_two\n" +
129+
" '); \n" +
130+
"END; ";
128131
dbaConn.execute(
129132
sql,
130133
function(err) {
@@ -135,7 +138,20 @@ describe('160. editionTest.js', function() {
135138
},
136139
// Create user
137140
function(cb) {
138-
var sql = "CREATE USER nodb_schema_edition IDENTIFIED BY nodb_schema_edition";
141+
let sql = "BEGIN \n" +
142+
" DECLARE \n" +
143+
" e_user_missing EXCEPTION; \n" +
144+
" PRAGMA EXCEPTION_INIT(e_user_missing, -01918); \n" +
145+
" BEGIN \n" +
146+
" EXECUTE IMMEDIATE('DROP USER nodb_schema_edition CASCADE'); \n" +
147+
" EXCEPTION \n" +
148+
" WHEN e_user_missing \n" +
149+
" THEN NULL; \n" +
150+
" END; \n" +
151+
" EXECUTE IMMEDIATE (' \n" +
152+
" CREATE USER nodb_schema_edition IDENTIFIED BY nodb_schema_edition\n" +
153+
" '); \n" +
154+
"END; ";
139155
dbaConn.execute(
140156
sql,
141157
function(err) {

0 commit comments

Comments
 (0)