Skip to content

Commit

Permalink
Move t.end() calls earlier to avoid confusion
Browse files Browse the repository at this point in the history
The orderer.js tests contain asynchronous calls that are expected
to fail because of the negative tests. Currently the t.end() call
is placed at the outside of the callbacks, this results in the
error being printed AFTER the success printouts for the test suite.

This is confusing when running `gulp test-headless` because errors
get printed out after the summary table and it may appear that
the test run has failed.

Change-Id: I35cee62ed0514a6075f31b50a1d911546e153362
Signed-off-by: Jim Zhang <jzhang@us.ibm.com>
  • Loading branch information
jimthematrix committed Feb 18, 2017
1 parent a4641aa commit f6a374c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/unit/orderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ test('orderer missing data test', function(t) {
function(status) {
console.log('response status: ' + JSON.stringify(status));
t.fail('Should have noticed missing data.');
t.end();
},
function(err) {
console.log('Caught Error: ' + err);
t.pass('Successfully found missing data: ' + err);
t.end();
}
).catch(function(err) {
t.fail('Caught Error: should not be here if we defined promise error function: ' + err);
t.end();
});
t.end();
});

//
Expand All @@ -113,13 +115,15 @@ test('orderer unknown address test', function(t) {
function(status) {
console.log('response status: ' + JSON.stringify(status));
t.fail('Should have noticed a bad address.');
t.end();
},
function(err) {
t.pass('Successfully found bad address!');
t.end();
}
).catch(function(err) {
t.fail('Caught Error: should not be here if we defined promise error function: '
+ err);
t.end();
});
t.end();
});

0 comments on commit f6a374c

Please sign in to comment.