Skip to content

Commit

Permalink
Tests: patching tests to reflect new semantics (reject update if no LAN)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Oct 16, 2015
1 parent 35729e9 commit 4356f52
Show file tree
Hide file tree
Showing 2 changed files with 182 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ controller.standardTesselCommand = function(opts, command) {
});
})
.catch(reject);
}).catch(function(error) {
return Promise.reject(error);
});
};

Expand Down
180 changes: 180 additions & 0 deletions test/unit/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ exports['controller.update'] = {
buildOptionValid: function(test) {
test.expect(9);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {}
});

var binaries = {
firmware: new Buffer(0),
openwrt: new Buffer(0)
Expand Down Expand Up @@ -142,9 +157,40 @@ exports['controller.update'] = {
});
},

buildWillNotUpdateOverUSB: function(test) {
test.expect(1);

var opts = {
version: '0.0.1'
};

controller.update(opts)
.catch(function(error) {
test.equal(error, 'No LAN connection found. USB-only updates do not work yet. Please ensure Tessel is connected to wifi and try again');
test.done();
});
},

buildOptionInvalid: function(test) {
test.expect(3);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {
return Promise.resolve();
}
});

var errMessage = 'No such build exists';

this.fetchBuild = this.sandbox.stub(updates, 'fetchBuild', function() {
Expand All @@ -169,6 +215,21 @@ exports['controller.update'] = {
buildLatest: function(test) {
test.expect(8);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {}
});

var binaries = {
firmware: new Buffer(0),
openwrt: new Buffer(0)
Expand Down Expand Up @@ -213,6 +274,23 @@ exports['controller.update'] = {
buildLatestAlreadyCurrent: function(test) {
test.expect(7);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {
return Promise.resolve();
}
});

var binaries = {
firmware: new Buffer(0),
openwrt: new Buffer(0)
Expand Down Expand Up @@ -246,6 +324,23 @@ exports['controller.update'] = {
buildLatestUpdateFailed: function(test) {
test.expect(7);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {
return Promise.resolve();
}
});

var binaries = {
firmware: new Buffer(0),
openwrt: new Buffer(0)
Expand Down Expand Up @@ -290,6 +385,23 @@ exports['controller.update'] = {
buildLatestForce: function(test) {
test.expect(7);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {
return Promise.resolve();
}
});

var binaries = {
firmware: new Buffer(0),
openwrt: new Buffer(0)
Expand Down Expand Up @@ -329,6 +441,23 @@ exports['controller.update'] = {
explicitLatestDoesntImmediatelyUpdate: function(test) {
test.expect(3);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {
return Promise.resolve();
}
});

var binaries = {
firmware: new Buffer(0),
openwrt: new Buffer(0)
Expand Down Expand Up @@ -359,6 +488,23 @@ exports['controller.update'] = {
noVerifiedVersion: function(test) {
test.expect(2);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {
return Promise.resolve();
}
});

var opts = {
version: 'x.x.x'
};
Expand All @@ -374,6 +520,23 @@ exports['controller.update'] = {
noVersionForcedUpdate: function(test) {
test.expect(4);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {
return Promise.resolve();
}
});

this.fetchCurrentBuildInfo.restore();
this.fetchCurrentBuildInfo = this.sandbox.stub(Tessel.prototype, 'fetchCurrentBuildInfo', function() {
return Promise.reject(new Error('[Error: cat: can\'t open \'/etc/tessel-version\': No such file or directory]'));
Expand Down Expand Up @@ -409,6 +572,23 @@ exports['controller.update'] = {
noVersionUnknownError: function(test) {
test.expect(4);

// This Tessel instance MUST be connected via BOTH
//
// - USB
// - LAN (authorized)
//
this.tessel = TesselSimulator({
type: 'LAN',
authorized: true,
});

this.tessel.addConnection({
connectionType: 'USB',
end: function() {
return Promise.resolve();
}
});

var unknownError = new Error('Something totally weird happened.');

this.fetchCurrentBuildInfo.restore();
Expand Down

0 comments on commit 4356f52

Please sign in to comment.