diff --git a/README.md b/README.md
index ae738c4c2b..854c01e358 100755
--- a/README.md
+++ b/README.md
@@ -25,6 +25,16 @@ To run the app in development:
- `npm run release`
+### Unit Tests
+
+- `npm test`
+
+### Integration Tests
+
+Note that integration tests need to be run a Mac and _will_ remove your existing Boot2Docker VM, containers etc.
+
+- `npm run test:integration`
+
## Uninstalling
- Remove Kitematic.app
diff --git a/package.json b/package.json
index a80e514676..9371f56922 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"scripts": {
"start": "gulp",
"test": "gulp test --silent",
- "integration-tests": "gulp test --silent --integration",
+ "test:integration": "gulp test --silent --integration",
"all-tests": "npm test && npm run integration-tests",
"release": "gulp run release",
"preinstall": "./deps"
diff --git a/specs/tests.js b/specs/tests.js
deleted file mode 100644
index 394df65268..0000000000
--- a/specs/tests.js
+++ /dev/null
@@ -1,26 +0,0 @@
-window.jasmineRequire = require('./jasmine-2.1.3/jasmine');
-require('./jasmine-2.1.3/jasmine-html');
-require('./jasmine-2.1.3/boot');
-var consoleReporter = require('./jasmine-2.1.3/console');
-var app = require('remote').require('app');
-
-jasmine.getEnv().addReporter(new consoleReporter.ConsoleReporter()({
- showColors: true,
- timer: new jasmine.Timer(),
- print: function() {
- process.stdout.write.apply(process.stdout, arguments);
- },
- onComplete: function () {
- app.quit();
- }
-}));
-
-console.log('hi');
-var fs = require('fs');
-var tests = fs.readdirSync('./tests').filter(function (f) {
- return f.indexOf('-' + process.env.TEST_TYPE) !== -1;
-});
-
-tests.forEach(function (t) {
- require('./' + t);
-});
diff --git a/src/Boot2Docker.js b/src/Boot2Docker.js
index 8e64baedc4..669a3f8f9f 100644
--- a/src/Boot2Docker.js
+++ b/src/Boot2Docker.js
@@ -84,7 +84,13 @@ var Boot2Docker = {
cmdExec([Boot2Docker.command(), 'upgrade'], callback);
},
ip: function (callback) {
- cmdExec([Boot2Docker.command(), 'ip'], callback);
+ exec([Boot2Docker.command(), 'ip'], function (stderr, stdout, code) {
+ if (code) {
+ callback(stderr);
+ } else {
+ callback(null, stdout.trim().replace('\n', ''));
+ }
+ });
},
erase: function (callback) {
var VMFileLocation = path.join(homeDir(), 'VirtualBox\\ VMs/boot2docker-vm');
diff --git a/src/ContainerDetails.react.js b/src/ContainerDetails.react.js
index d753ef7c05..8ee442168b 100644
--- a/src/ContainerDetails.react.js
+++ b/src/ContainerDetails.react.js
@@ -76,7 +76,7 @@ var ContainerDetails = React.createClass({
var $viewPopover = $(this.getDOMNode()).find('.popover-view');
var $volumePopover = $(this.getDOMNode()).find('.popover-volume');
- if ($viewDropdown && $volumeDropdown && $viewPopover && $volumePopover) {
+ if ($viewDropdown.offset() && $volumeDropdown.offset()) {
$viewPopover.offset({
top: $viewDropdown.offset().top + 32,
left: $viewDropdown.offset().left - ($viewPopover.outerWidth() / 2) + 14
@@ -94,16 +94,19 @@ var ContainerDetails = React.createClass({
return;
}
this.setState({
+ progress: ContainerStore.progress(this.getParams().name),
env: ContainerUtil.env(container),
});
var ports = ContainerUtil.ports(container);
var webPorts = ['80', '8000', '8080', '3000', '5000', '2368'];
+ console.log(ports);
this.setState({
ports: ports,
defaultPort: _.find(_.keys(ports), function (port) {
return webPorts.indexOf(port) !== -1;
})
});
+ console.log(this.state);
this.updateLogs();
},
updateLogs: function (name) {
@@ -134,6 +137,7 @@ var ContainerDetails = React.createClass({
handleView: function () {
if (this.state.defaultPort) {
console.log(this.state.defaultPort);
+ console.log(this.state.ports[this.state.defaultPort].url);
exec(['open', this.state.ports[this.state.defaultPort].url], function (err) {
if (err) { throw err; }
});
@@ -159,11 +163,6 @@ var ContainerDetails = React.createClass({
console.log(err);
});
},
- handleRestart: function () {
- ContainerStore.restart(this.props.container.Name, function (err) {
- console.log(err);
- });
- },
handleTerminal: function () {
var container = this.props.container;
var terminal = path.join(process.cwd(), 'resources', 'terminal').replace(/ /g, '\\\\ ');
@@ -310,6 +309,13 @@ var ContainerDetails = React.createClass({
disabled: !this.props.container.State.Running
});
+ var restartButtonClass = React.addons.classSet({
+ btn: true,
+ 'btn-action': true,
+ 'with-icon': true,
+ disabled: this.props.container.State.Restarting
+ });
+
var viewButtonClass = React.addons.classSet({
btn: true,
'btn-action': true,
@@ -444,7 +450,7 @@ var ContainerDetails = React.createClass({
Volumes
Terminal
diff --git a/src/ContainerModal.react.js b/src/ContainerModal.react.js
index b9d862a7dd..64543d6f5f 100644
--- a/src/ContainerModal.react.js
+++ b/src/ContainerModal.react.js
@@ -83,6 +83,9 @@ var ContainerModal = React.createClass({
},
handleClick: function (name, event) {
ContainerStore.create(name, 'latest', function (err, containerName) {
+ if (err) {
+ throw err;
+ }
this.props.onRequestHide();
}.bind(this));
},
diff --git a/src/ContainerStore.js b/src/ContainerStore.js
index 3f304fad0a..82f3eaa4e2 100644
--- a/src/ContainerStore.js
+++ b/src/ContainerStore.js
@@ -18,7 +18,6 @@ var _progress = {};
var _logs = {};
var _streams = {};
var _muted = {};
-var _config = {};
var ContainerStore = assign(EventEmitter.prototype, {
CLIENT_CONTAINER_EVENT: 'client_container',
@@ -250,7 +249,12 @@ var ContainerStore = assign(EventEmitter.prototype, {
init: function (callback) {
// TODO: Load cached data from db on loading
this.fetchAllContainers(function (err) {
- callback();
+ if (err) {
+ callback(err);
+ return;
+ } else {
+ callback();
+ }
this.emit(this.CLIENT_CONTAINER_EVENT);
this._resumePulling();
this._startListeningToEvents();
@@ -366,7 +370,6 @@ var ContainerStore = assign(EventEmitter.prototype, {
});
stream.on('end', function () {
delete _streams[name];
- console.log('end', name);
});
});
},
@@ -381,6 +384,10 @@ var ContainerStore = assign(EventEmitter.prototype, {
if (!data) {
// Pull image
self._createPlaceholderContainer(imageName, containerName, function (err, container) {
+ if (err) {
+ callback(err);
+ return;
+ }
_containers[containerName] = container;
self.emit(self.CLIENT_CONTAINER_EVENT, containerName, 'create');
_muted[containerName] = true;
diff --git a/src/ContainerUtil.js b/src/ContainerUtil.js
index 86aebd701a..61159f7186 100644
--- a/src/ContainerUtil.js
+++ b/src/ContainerUtil.js
@@ -15,9 +15,8 @@ var ContainerUtil = {
ports: function (container, callback) {
var res = {};
var ip = docker.host;
- console.log(container);
_.each(container.NetworkSettings.Ports, function (value, key) {
- var dockerPort = key;
+ var dockerPort = key.split('/')[0];
var localUrl = null;
var localUrlDisplay = null;
if (value && value.length) {
diff --git a/src/Docker.js b/src/Docker.js
index ac9701546a..6c8768bf2e 100644
--- a/src/Docker.js
+++ b/src/Docker.js
@@ -12,8 +12,7 @@ var Docker = {
return;
}
this._client = new dockerode({
- protocol: 'https',
- host: this.host,
+ host: '192.168.59.103',
port: 2376,
ca: fs.readFileSync(path.join(certDir, 'ca.pem')),
cert: fs.readFileSync(path.join(certDir, 'cert.pem')),
diff --git a/src/Main.js b/src/Main.js
index d908e18656..e58c34486a 100644
--- a/src/Main.js
+++ b/src/Main.js
@@ -2,7 +2,7 @@ var React = require('react');
var Router = require('react-router');
var RetinaImage = require('react-retina-image');
var async = require('async');
-var docker = require('./docker');
+var docker = require('./Docker');
var router = require('./router');
var boot2docker = require('./boot2docker');
var ContainerStore = require('./ContainerStore');
@@ -29,9 +29,11 @@ if (process.env.NODE_ENV === 'development') {
if (!window.location.hash.length || window.location.hash === '#/') {
SetupStore.run(function (err) {
boot2docker.ip(function (err, ip) {
+ if (err) console.log(err);
docker.setHost(ip);
router.transitionTo('containers');
- ContainerStore.init(function () {
+ ContainerStore.init(function (err) {
+ if (err) console.log(err);
router.run(function (Handler) {
React.render(
, document.body);
});
@@ -40,8 +42,10 @@ if (!window.location.hash.length || window.location.hash === '#/') {
});
} else {
boot2docker.ip(function (err, ip) {
+ if (err) console.log(err);
docker.setHost(ip);
- ContainerStore.init(function () {
+ ContainerStore.init(function (err) {
+ if (err) console.log(err);
router.run(function (Handler) {
React.render(
, document.body);
});
diff --git a/tests/SetupStore-integration.js b/tests/SetupStore-integration.js
index 4060a12812..2dde66b446 100644
--- a/tests/SetupStore-integration.js
+++ b/tests/SetupStore-integration.js
@@ -17,12 +17,10 @@ describe('Setup', function () {
if (fs.existsSync(virtualboxFile)) {
fs.unlinkSync(virtualboxFile);
}
- spyOn(virtualbox, 'installed').andCallFake(function (callback) {
- callback(false);
- });
+ spyOn(virtualbox, 'installed').and.returnValue(false);
});
- it('downloads virtualbox', function (done) {
+ it('downloads virtualbox from the official website', function (done) {
SetupStore.downloadVirtualboxStep.run(function (err) {
expect(err).toBeFalsy();
expect(fs.existsSync(virtualboxFile)).toBe(true);
@@ -51,6 +49,7 @@ describe('Setup', function () {
it('does install virtualbox', function (done) {
SetupStore.installVirtualboxStep.run(function (err) {
expect(err).toBeFalsy();
+ expect(fs.existsSync(virtualbox.command())).toBe(true);
done();
});
});