var Bluebird = require('bluebird');
var connection = require('./connection');
var errors = require('./errors');

var mockOptions = {},
    offlineMode = false;

module.exports.errors = errors;

module.exports.connect = function connect(options) {
  if (offlineMode) {
    throw new Error("Real connections to " + options.host + " are not allowed in offline mode");
  }
  return new connection.Connection(options).connect();
};

module.exports.connectMock = function connectMock(options) {
  return new connection.MockConnection(options, mockOptions).connect();
};

module.exports.setMockOptions = function setMockOptions(options) {
  mockOptions = options;
};

module.exports.setOfflineMode = function setOfflineMode(value) {
 offlineMode = !!value;
};

var Bluebird = require('bluebird');
var connection = require('./connection');
var errors = require('./errors');

var mockOptions = {};

module.exports.errors = errors;

module.exports.connect = function connect(options) {
  return new connection.Connection(options).connect();
};

module.exports.connectMock = function connectMock(options) {
  return new connection.MockConnection(options, mockOptions).connect();
};

module.exports.setMockOptions = function setMockOptions(options) {
  mockOptions = options;
};

--- 
+++ 
@@ -2,11 +2,15 @@
 var connection = require('./connection');
 var errors = require('./errors');
 
-var mockOptions = {};
+var mockOptions = {},
+    offlineMode = false;
 
 module.exports.errors = errors;
 
 module.exports.connect = function connect(options) {
+  if (offlineMode) {
+    throw new Error("Real connections to " + options.host + " are not allowed in offline mode");
+  }
   return new connection.Connection(options).connect();
 };
 
@@ -17,3 +21,7 @@
 module.exports.setMockOptions = function setMockOptions(options) {
   mockOptions = options;
 };
+
+module.exports.setOfflineMode = function setOfflineMode(value) {
+ offlineMode = !!value;
+};
Add option to prevent real connections in test mode
