Skip to content

Commit

Permalink
tests: check callcounts and args for remoteRustCompilation and runBuild
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Oct 24, 2016
1 parent 68acee2 commit 99c353f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/tessel/deployment/rust.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ exportables.tarBundle = function(opts) {
return exportables.remoteRustCompilation(opts);
} else {
return rust.runBuild({
isCli: true,
binary: opts.resolvedEntryPoint,
path: opts.target
})
isCli: true,
binary: opts.resolvedEntryPoint,
path: opts.target
})
.then(tarball => fs.readFileSync(tarball));
}
};
Expand Down
14 changes: 12 additions & 2 deletions test/unit/deployment/rust.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ exports['deploy.rust'] = {
},

rustTarBundleLocal: function(test) {
test.expect(1);
test.expect(4);

this.remoteRustCompilation = sandbox.stub(deployment.rs, 'remoteRustCompilation', () => Promise.resolve(null));

Expand All @@ -250,14 +250,21 @@ exports['deploy.rust'] = {
deployment.rs.tarBundle(opts)
.then((tarball) => {
test.ok(Buffer.isBuffer(tarball), 'tarball should be buffer');
test.equal(this.remoteRustCompilation.callCount, 0);
test.equal(this.runBuild.callCount, 1);
test.deepEqual(this.runBuild.lastCall.args[0], {
isCli: true,
binary: undefined,
path: undefined
});
}, error => {
test.ok(false, error.toString());
})
.then(() => test.done());
},

rustTarBundleRemote: function(test) {
test.expect(1);
test.expect(4);

this.remoteRustCompilation = sandbox.stub(deployment.rs, 'remoteRustCompilation', () => Promise.resolve(new Buffer([])));

Expand All @@ -271,6 +278,9 @@ exports['deploy.rust'] = {
deployment.rs.tarBundle(opts)
.then((tarball) => {
test.ok(Buffer.isBuffer(tarball), 'tarball should be buffer');
test.equal(this.runBuild.callCount, 0);
test.equal(this.remoteRustCompilation.callCount, 1);
test.deepEqual(this.remoteRustCompilation.lastCall.args[0], opts);
}, error => {
test.ok(false, error.toString());
})
Expand Down

0 comments on commit 99c353f

Please sign in to comment.