Skip to content

Commit fab3d5e

Browse files
committed
Add more error offset tests
1 parent f9744ae commit fab3d5e

File tree

2 files changed

+63
-5
lines changed

2 files changed

+63
-5
lines changed

test/errorOffset.js

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,24 @@ const dbconfig = require('./dbconfig.js');
3333

3434
describe('240. errorOffset.js', async () => {
3535

36-
it('240.1 checks the offset value of the error', async () => {
37-
let conn;
36+
let conn;
37+
before(async () => {
3838
try {
3939
conn = await oracledb.getConnection(dbconfig);
4040
} catch (error) {
4141
should.not.exist(error);
4242
}
43+
});
44+
45+
after(async () => {
46+
try {
47+
await conn.close();
48+
} catch (error) {
49+
should.not.exist(error);
50+
}
51+
});
52+
53+
it('240.1 checks the offset value of the error', async () => {
4354

4455
try {
4556
await conn.execute("begin t_Missing := 5; end;");
@@ -49,10 +60,54 @@ describe('240. errorOffset.js', async () => {
4960
should.strictEqual(error.errorNum, 6550);
5061
}
5162

63+
}); // 240.1
64+
65+
it('240.2 database error', async () => {
66+
67+
const plsql = `
68+
begin
69+
execute immediate ('drop table nodb_table_nonexistent');
70+
end;
71+
`;
5272
try {
53-
await conn.close();
73+
await conn.execute(plsql);
5474
} catch (error) {
55-
should.not.exist(error);
75+
should.exist(error);
76+
should.strictEqual(error.offset, 0);
77+
should.strictEqual(error.errorNum, 942);
5678
}
57-
});
79+
80+
}); // 240.2
81+
82+
it('240.3 the offset of system error is 0', async () => {
83+
const plsql = `
84+
BEGIN
85+
DECLARE v_invalid PLS_INTEGER;
86+
BEGIN
87+
v_invalid := 100/0;
88+
END;
89+
END;
90+
`;
91+
try {
92+
await conn.execute(plsql);
93+
} catch (error) {
94+
should.exist(error);
95+
should.strictEqual(error.offset, 0);
96+
should.strictEqual(error.errorNum, 1476);
97+
}
98+
});// 240.3
99+
100+
it('240.4 PL/SQL syntax error', async () => {
101+
const plsql = `DECLARE v_missing_semicolon PLS_INTEGER
102+
BEGIN
103+
v_missing_semicolon := 46;
104+
END;`;
105+
try {
106+
await conn.execute(plsql);
107+
} catch (error) {
108+
should.exist(error);
109+
should.strictEqual(error.offset, 46);
110+
should.strictEqual(error.errorNum, 6550);
111+
}
112+
}); // 240.4
58113
});

test/list.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,3 +4739,6 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
47394739

47404740
240. errorOffset.js
47414741
240.1 checks the offset value of the error
4742+
240.2 database error
4743+
240.3 the offset of system error is 0
4744+
240.4 PL/SQL syntax error

0 commit comments

Comments
 (0)