Skip to content

Commit 7a9434f

Browse files
committed
Add basic tests for connection.ping()
1 parent a9adc9b commit 7a9434f

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

test/connection.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,4 +879,66 @@ describe('1. connection.js', function(){
879879

880880
}); // 1.8
881881

882+
describe('1.9 Ping method', function() {
883+
884+
it('1.9.1 ping() checks the connection is usable', function(done) {
885+
var conn;
886+
async.series([
887+
function(cb) {
888+
oracledb.getConnection(
889+
dbConfig,
890+
function(err, connection) {
891+
should.not.exist(err);
892+
conn = connection;
893+
cb();
894+
}
895+
);
896+
},
897+
function(cb) {
898+
conn.ping(function(err) {
899+
should.not.exist(err);
900+
cb();
901+
});
902+
},
903+
function(cb) {
904+
conn.close(function(err) {
905+
should.not.exist(err);
906+
cb();
907+
});
908+
}
909+
], done);
910+
}); // 1.9.1
911+
912+
it('1.9.2 closed connection', function(done) {
913+
var conn;
914+
async.series([
915+
function(cb) {
916+
oracledb.getConnection(
917+
dbConfig,
918+
function(err, connection) {
919+
should.not.exist(err);
920+
conn = connection;
921+
cb();
922+
}
923+
);
924+
},function(cb) {
925+
conn.close(function(err) {
926+
should.not.exist(err);
927+
cb();
928+
});
929+
},
930+
function(cb) {
931+
conn.ping(function(err) {
932+
should.exist(err);
933+
should.strictEqual(
934+
err.message,
935+
"NJS-003: invalid connection"
936+
);
937+
cb();
938+
});
939+
},
940+
], done);
941+
}); // 1.9.2
942+
}); // 1.9
943+
882944
});

test/list.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Overview of node-oracledb functional tests
3131
1.8.3 Negative value - random constants
3232
1.8.4 Negative value - NaN
3333
1.8.5 gets ignored when acquiring a connection from Pool
34+
1.9 Ping method
35+
1.9.1 ping() checks the connection is usable
36+
1.9.2 closed connection
3437

3538
2. pool.js
3639
2.1 default values

0 commit comments

Comments
 (0)