Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
test: crypto-domains avoid spurious failures
Browse files Browse the repository at this point in the history
The order of the callbacks is non-deterministic, so don't expect the
error messages to come back in the same order every time, instead just
verify they are expected messages.
  • Loading branch information
tjfontaine committed Oct 16, 2014
1 parent d601c76 commit 2afa3d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/simple/test-crypto-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ var d = domain.create();
var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes']

d.on('error', function (e) {
assert.equal(e.message, expect.shift());
var idx = expect.indexOf(e.message);
assert.notEqual(idx, -1, 'we should have error: ' + e.message);
expect.splice(idx, 1);
});

d.run(function () {
Expand All @@ -42,3 +44,7 @@ d.run(function () {
throw new Error('pseudoRandomBytes');
});
});

process.on('exit', function () {
assert.strictEqual(expect.length, 0, 'we should have seen all error messages');
});

0 comments on commit 2afa3d8

Please sign in to comment.