Permalink
Browse files

BEANSTALK_PORT env, slight change to test helper

  • Loading branch information...
1 parent 5576a7c commit c93cc31c286e4932924d29e380fab7df3bb2edf5 @pascalopitz committed Mar 11, 2013
Showing with 20 additions and 19 deletions.
  1. +20 −19 tests/helper.js
View
@@ -1,7 +1,7 @@
var bs = require('../lib/beanstalk_client');
var net = require('net');
-var port = process.env.PORT || 11333;
+var port = process.env.BEANSTALK_PORT || 11333;
var mock = process.env.BEANSTALKD !== '1';
var mock_server;
@@ -11,30 +11,31 @@ var connection;
module.exports = {
bind : function (fn, closeOnEnd) {
- if(mock) {
- mock_server = net.createServer(function(conn) {
- connection = conn;
+ if(!mock) {
+ return false;
+ }
- connection.on('data', function (data) {
- fn.call(mock_server, connection, data);
- });
+ mock_server = net.createServer(function(conn) {
+ connection = conn;
- if(closeOnEnd === true) {
- closeOnEnd = function () {
- mock_server.close();
- }
- }
+ connection.on('data', function (data) {
+ fn.call(mock_server, connection, data);
+ });
- if(closeOnEnd) {
- connection.on('end', function () {
- closeOnEnd.call(mock_server);
- });
+ if(closeOnEnd === true) {
+ closeOnEnd = function () {
+ mock_server.close();
}
- });
+ }
- mock_server.listen(port);
- }
+ if(closeOnEnd) {
+ connection.on('end', function () {
+ closeOnEnd.call(mock_server);
+ });
+ }
+ });
+ mock_server.listen(port);
},
getClient : function () {
return bs.Client('127.0.0.1:' + port);

0 comments on commit c93cc31

Please sign in to comment.