Skip to content

Commit

Permalink
fix: endpoint test for node v10. server.close() does not behave like …
Browse files Browse the repository at this point in the history
…it did in node v8 & node v6.
  • Loading branch information
FGRibreau committed Oct 30, 2018
1 parent 89d7a64 commit b8f1fe1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lib/Endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ module.exports = function(log, jsonPackage, tls, process) {
/**
* Endpoint (redsmin)
* @param {Function} fnWrite `callback(data)` where to write datas from the endpoint
* @param {String} key Connection key
* @param {String} key Connection key
* @param {Number,String} port Connection-server port
* @param {String} hostname Connection-server hostname
* @param {Object} opts Optional parameters
*/
function Endpoint(fnWrite, key, port, hostname, opts) {
Expand Down
13 changes: 6 additions & 7 deletions lib/Endpoint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ var tls = require('tls');
var sinon = require('sinon');
var Socket = require('../test/helpers/Socket');
var t = require('chai').assert;
var debug = require('debug')('Endpoint.test');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
describe('Endpoint', function() {

var Endpoint, E, log, jsonPackage, tlsOverride, process;
// dummy values
var HOSTNAME = 'ssl.redsmin.dev';
var PORT = 433;

Expand Down Expand Up @@ -42,10 +44,6 @@ describe('Endpoint', function() {
done();
});

afterEach(function(done) {
done();
});

describe('with a socket server', function() {
var address;
var server;
Expand All @@ -55,7 +53,7 @@ describe('Endpoint', function() {
key: fs.readFileSync(path.resolve(__dirname, 'server-key.fixtures.pem')),
cert: fs.readFileSync(path.resolve(__dirname, 'server-cert.fixtures.pem')),
}, function (socket) {
console.log('got a new socket');
debug('got a new socket');
setTimeout(function() {
try{
socket.end('goodbye\n');
Expand All @@ -70,13 +68,14 @@ describe('Endpoint', function() {

server.listen(function(){
address = server.address();
console.log('opened server on %j', address);
debug('opened server on %j', address);
done();
});
});

afterEach(function(done) {
server.close(done);
server.close();
done();
});

it('should handle race connect/disconnect', function(done) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"node_modules",
"dist",
"test/**",
"*.test.js",
"webpack.config.js",
"*.js"
]
Expand Down

0 comments on commit b8f1fe1

Please sign in to comment.