Skip to content

Commit

Permalink
Use the sha when there is no "official" build version available.
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Jun 15, 2017
1 parent 1c81a03 commit 35a4f07
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,10 @@ controller.tesselEnvVersions = opts => {
responses[2] => (string) process.version (on board)
*/

var cliVersion = require('../package.json').version;
var firmwareVersion = updates.findBuild(responses[0], 'sha', responses[1]).version;
var nodeVersion = responses[2];
const cliVersion = require('../package.json').version;
const build = updates.findBuild(responses[0], 'sha', responses[1]);
const firmwareVersion = (build && build.version) || responses[1];
const nodeVersion = responses[2];

log.info('Tessel Environment Versions:');
log.info(`t2-cli: ${cliVersion}`);
Expand Down
25 changes: 25 additions & 0 deletions test/unit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,31 @@ exports['controller.tesselEnvVersions'] = {
test.done();
});
},

// This happens with development builds.
noBuildVersionExistsForThisSha(test) {
test.expect(4);

const sha = '59ce9c97e275e6e970c1ee668e5591514eb1cd74';

this.fetchCurrentBuildInfo.restore();
this.sandbox.stub(this.tessel, 'fetchCurrentBuildInfo', () => Promise.resolve(sha));

var opts = {};

controller.tesselEnvVersions(opts)
.then(() => {
test.equal(this.info.getCall(0).args[0], 'Tessel Environment Versions:');
test.equal(this.info.getCall(1).args[0], 't2-cli: 0.1.4');
test.equal(this.info.getCall(2).args[0], `t2-firmware: ${sha}`);
test.equal(this.info.getCall(3).args[0], 'Node.js: 4.2.1');
test.done();
})
.catch(() => {
test.ok(false);
test.done();
});
},
};

exports['Tessel.list'] = {
Expand Down

0 comments on commit 35a4f07

Please sign in to comment.