Skip to content

Commit

Permalink
t2 run/push: tests for deployment.js.logMissingBinaryModuleWarning
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 Sep 21, 2016
1 parent f72da03 commit 8875cd3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/tessel/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ exportables.postRun = function(tessel, options) {
return Promise.resolve();
};

exportables.logMissingBinaryModuleWarning = function(name, version) {
exportables.logMissingBinaryModuleWarning = function(details) {
var warning = tags.stripIndent `
Pre-compiled module is missing: ${name}@${version}.
Pre-compiled module is missing: ${details.name}@${details.version}.
Please an file issue at https://github.com/tessel/t2-cli/issues/new with this warning.
This warning might be caused by one of the following:
Expand Down Expand Up @@ -373,7 +373,7 @@ exportables.injectBinaryModules = function(globRoot, tempBundlePath, options) {
fs.copySync(sourceBinaryPath, tempTargetBinaryPath);
isCopied = true;
} catch (error) {
exportables.logMissingBinaryModuleWarning(details.name);
exportables.logMissingBinaryModuleWarning(details);
log.error(error);
}
}
Expand All @@ -388,7 +388,7 @@ exportables.injectBinaryModules = function(globRoot, tempBundlePath, options) {
} else {
// In the future we may allow users to log the ignored modules here
if (!details.ignored) {
exportables.logMissingBinaryModuleWarning(details.name, details.version);
exportables.logMissingBinaryModuleWarning(details);
}
}
});
Expand Down
41 changes: 41 additions & 0 deletions test/unit/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -2905,3 +2905,44 @@ exports['deployment.js.postRun'] = {
});
},
};

exports['deployment.js.logMissingBinaryModuleWarning'] = {
setUp: function(done) {
this.warn = sandbox.stub(log, 'warn');
this.details = {
binName: 'compiled-binary.node',
buildPath: path.normalize('/build/Release/node-v46-FAKE_PLATFORM-FAKE_ARCH/'),
buildType: 'Release',
globPath: path.normalize('node_modules/compiled-binary/build/Release/node-v46-FAKE_PLATFORM-FAKE_ARCH/compiled-binary.node'),
ignored: false,
name: 'compiled-binary',
modulePath: path.normalize('node_modules/compiled-binary'),
resolved: true,
version: '2.0.6',
extractPath: path.normalize('~/.tessel/binaries/compiled-binary-2.0.6-Release-node-v46-linux-mipsel')
};
done();
},
tearDown: function(done) {
sandbox.restore();
done();
},

callsThroughToLogWarn: function(test) {
test.expect(1);
deployment.js.logMissingBinaryModuleWarning(this.details);
test.equal(this.warn.callCount, 1);
test.done();
},

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

deployment.js.logMissingBinaryModuleWarning(this.details);

var output = this.warn.lastCall.args[0];

test.equal(output.includes('Pre-compiled module is missing: compiled-binary@2.0.6'), true);
test.done();
},
};

0 comments on commit 8875cd3

Please sign in to comment.